<?php
$post_type = 'car';
$tax = 'sponsorship';
$post_count = 5;
$counter = 0;
$tax_terms = get_terms($tax);
echo 'Related Advice';
if ($tax_terms) {
foreach ($tax_terms as $tax_term) {
$args = array(
'post_type' => $post_type,
"$tax" => $tax_term->slug,
'post_status' => 'publish',
'orderby' => rand
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
echo '<ul class="sponsorship-post-list">';
while ($my_query->have_posts() && $counter < $post_count) : $my_query->the_post(); ?>
<li>
<h3 class="sponsorship-post"><?php the_title(); ?></h3>
<?php the_excerpt(); ?>
</li>
<?php
$counter += 1;
endwhile;
echo '</ul>';
}
wp_reset_query();
}
}
?>
$post_type = 'car';
$tax = 'sponsorship';
$post_count = 5;
$counter = 0;
$tax_terms = get_terms($tax);
echo 'Related Advice';
if ($tax_terms) {
foreach ($tax_terms as $tax_term) {
$args = array(
'post_type' => $post_type,
"$tax" => $tax_term->slug,
'post_status' => 'publish',
'orderby' => rand
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
echo '<ul class="sponsorship-post-list">';
while ($my_query->have_posts() && $counter < $post_count) : $my_query->the_post(); ?>
<li>
<h3 class="sponsorship-post"><?php the_title(); ?></h3>
<?php the_excerpt(); ?>
</li>
<?php
$counter += 1;
endwhile;
echo '</ul>';
}
wp_reset_query();
}
}
?>
Comments
Post a Comment