Search resulty by category

Discussion in 'WordPress' started by secretdesign, Sep 6, 2014.

  1. #1
    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(count)
    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 } ?>
    Code (markup):
    Thank you.
     
    secretdesign, Sep 6, 2014 IP