`<?php echo get_the_category_list(); ?>` not give me all my categories
-
06-07-2021 - |
Pregunta
<?php echo get_the_category_list(); ?>
not give me all my categories.
I use <?php echo get_the_category_list(); ?>
in my footer.php
file to display my categories but in home page show only two categories and in inner single posts show post's related category and in pages show nothing.
even I use <?php wp_reset_query(); ?>
after each WP_Query
please help me
Solución
You can use
<ul>
<?php wp_list_categories('exclude=22&title_li='); ?>
</ul>
Otros consejos
$categories = get_categories($args);
$html = '<ul>';
foreach($categories as $cat){
$html .= '<li><a href="'.get_permalink($cat->term_id);.'"';
$html .= '<h2>'.$cat->cat_name.'</h2>';
$html .= '</a></li>';
}
$html .= '';
return $html;`
in your function
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow