Ottenere custom post type per tag
È possibile recuperare le voci dei custom post type tramite tag? Ho provato con il seguente codice, ma finisco in un loop infinito.
<aside class="supporting_images">
<?php /*<?php if($post->ID == 241) : echo apply_filters('the_content', '[slideshow=3]'); endif; ?>
<?php the_post_thumbnail(); ?>*/?>
<?php if($post->ID == 241) : ?>
<?php
$query = new WP_Query();
$query->query('tag=branding');
?>
<?php while ($query->have_posts()) : ?>
ciao
<?php endwhile; ?>
<?php endif;?>
Dovrai configurare il post per la query modificando la seguente riga per evitare il loop infinito.
<?php while ($query->have_posts()) : $query->the_post(); ?>
Se stai cercando un custom post type, dovrai specificarlo negli argomenti della query:
<?php $query = new WP_Query( array( "post-type" => "yourposttype", "tag" => "branding" ) ); ?>
Puoi vedere la maggior parte (se non tutti) i parametri della query nel codex. http://codex.wordpress.org/Class_Reference/WP_Query#Parameters

Utilizza tag_slug__in
invece di tag
(#REF)
Esempio:
$query = new WP_Query(array(
'post_status' => 'publish', // stato del post
'post_type' => 'your-posttype', // oppure 'any' per qualsiasi tipo
'tag_slug__in' => 'your-tag', // slug del tag da filtrare
'posts_per_page' => -1 // mostra tutti i post
));
Passaggio: Filtra per Tipo di Post prima poi filtra per Tag
Altre risposte suggeriscono "Filtra per Tipo di Post e filtra per Tag"
