• Guys, i want to show all categories even the categories have no post. and if the categories have post it will also display the content of the post.

    <?php $category = get_categories('hide_empty=0');
    foreach($category as $cat){
    echo $cat-> name;?>
    <?php echo ''?>
    <?php query_posts('cat=$cat');
    while(have_posts()) : the_post();?>
    <a>"><?php echo the_title();?></a>
    <?php the_content();?>
    <?php endwhile;
    }?>

    [Please use the code buttons when posting code here – as is, your code may have been corrupted by the forum’s parser.]

    this code will show all the categories but the problem is even if the post is not under the specific categories it will also display it under the categories. can anyone help me to edit this code. thanks

  • The topic ‘How to show all categories even the categories dont have post?’ is closed to new replies.