Support » Themes and Templates » Search results template

  • I’m trying to customize my search results template and am having trouble with one detail. For all of the results I have it set to display the category and other misc details. This is great for posts, but I don’t want to display that info for pages (i’m using a plugin to search both pages & posts).

    In the loop I need some kind of if/else statement to detect whether that item is a post or page. I’ve tried is_page() but that doesn’t work. What is the correct syntax to use to detect whether the post_type is page or post?

    I’ve also tried this but it doesn’t work:

    <?php if ($post_type = 'page') : ?>
    display this
    <?php else : ?>
    display something else
    <?php endif; ?>

Viewing 1 replies (of 1 total)
  • You tried is_page and it didn’t work? You could go manual and check the post by id and pull that variable using wpdb->get_var

Viewing 1 replies (of 1 total)
  • The topic ‘Search results template’ is closed to new replies.