• Hi,

    I’m trying to get something like this on my search results page…

    Cat 1(count)
    Post name
    Post name

    Cat 2(count)
    Post name
    Post name

    Cat 3(count)
    Post name

    Cat 4(post)
    Post name

    This is what I have for now:

    <?php
    $categories =   get_categories();
    $mycatid = $item->object_id;
    $category = get_category($mycatid );
    foreach($categories as $category) { 
    
    echo $category->name;
    
    echo $category->count;
    ?>
    
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    <?php the_title(); ?>
    
    <?php endwhile; ?>
    
    <?php include (TEMPLATEPATH . '/inc/nav.php' ); ?>  
    
    <?php else : ?>
    
    <h2 class="error">Not Found</h2>
    
    <?php endif; ?>
    
    <?php } ?>
  • The topic ‘Search resulty by category’ is closed to new replies.