With this code i get the last 3 posts that contain "solar-signs-related" tag on the custom post "product" page that have "solar-signs-streetscape-elements" term.
But how to combine two "if" so it will display also the blog posts that have "interior-system-related" tag if the custom post "products" page is "interior-systems"?
if ( has_term( 'interior-systems', 'categories' ) ) {
$args = array(
'post_type' => 'post',
'showposts' => 3,
'post__not_in' => array( $post->ID ),
'post_status' => array('publish'),
'orderby' => 'date',
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => 'post_tag',
'field' => 'slug',
'terms' => array('interior-systems-related') )
)
);
}
if ( has_term( 'solar-signs-streetscape-elements', 'categories' ) ) {
$args = array(
'post_type' => 'post',
'showposts' => 3,
'post__not_in' => array( $post->ID ),
'post_status' => array('publish'),
'orderby' => 'date',
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => 'post_tag',
'field' => 'slug',
'terms' => array('solar-signs-related') )
)
);
}
$query = new WP_Query($args);
if ($query->have_posts()) : while ($query->have_posts()) :
$query->the_post(); ?>
<div class="post-wrap relat relatblog">
<h2 class="entry-title"><?php the_title(); ?></h2>
</div>
<?php endwhile;
wp_reset_postdata();
endif;
endwhile; ?>
Aucun commentaire:
Enregistrer un commentaire