search post / pages results all in same category (3 posts)

  1. pjoern
    Posted 7 years ago #

    When I do a search on http://galleritheut.dk/wp/nyt/ (sorry, it's in Danish!) the search results show up correctly (E.g. http://galleritheut.dk/wp/?s=Nicaragua. Both post and pages are shown.

    However, results present static paces as belonging to category 'Sidste nyt'. It's the only category presently in use for my blog posts. However, I don't want static pages to be shown belonging to that category. They are in no category, really. I ticked those pages belonging to Parent: 'Main page (no parent).'

    So, why do pages turn up under a category they don't belong to?

  2. esmi
    Forum Moderator
    Posted 7 years ago #

    Quick fix. Edit search.php and look for a reference to <?php the_category();?>. Amend this to:

    <?php if($post->post_type == 'post') :?>
    <?php the_category();?>
    <?php endif;?>

    This will stop any category information being displayed unless the result refers to a WP Post.

  3. pjoern
    Posted 7 years ago #

    Thank you for the answer. That did it! Topic resolved.

    Anyway, finally I decided not to have category information shown at all on the search page.

Topic Closed

This topic has been closed to new replies.

About this Topic