In a custom taxonomy-category.php I want to show all the posts of this category, but with this code, it only shows posts if the category has more than one post.
What is incorrect?
<?php
$loop = mep_event_query(20, 'ASC', $term_id, '', '', '', 'upcoming');
if (have_posts() ):
while ( $loop->have_posts() ) : $loop->the_post();{
do_action('mep_event_list_shortcode', get_the_id(), 'four_column', 'grid');
}
wp_reset_postdata();
endwhile;
else: ?>
<p class="avis-no-cursos">En estos momentos no hay disponible ningun curso.</p>
<p class="boto-negre">
<a href="https://www.url" class="custom-link btn btn-sm border-width-0 btn-default btn-icon-right btn-ripple-out btn-border-animated cursor-init">Ver cursos disponibles<i class="fa fa-angle-right"></i></a>
</p>
<?php endif;
?>
2
$loop->have_posts(): We check for posts in a custom $loop request instead of using the global have_posts() function that works with the main WordPress loop.
$loop = mep_event_query(20, 'ASC', $term_id, '', '', '', 'upcoming');
if ( $loop->have_posts() ) :
while ( $loop->have_posts() ) :
do_action('mep_event_list_shortcode', get_the_ID(), 'four_column', 'grid');
endwhile;
wp_reset_postdata();
else :
?>
<p class="avis-no-cursos">En estos momentos no hay disponible ningun curso.</p>
<p class="boto-negre">
<a href="https://www.url" class="custom-link btn btn-sm border-width-0 btn-default btn-icon-right btn-ripple-out btn-border-animated cursor-init">
Ver cursos disponibles<i class="fa fa-angle-right"></i>
</a>
</p>
<?php
endif;
?>
New contributor
Itachi Uchiha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.