[resolved] Identify Post Type Filter on Search Results Page (2 posts)

  1. Mav3000
    Posted 4 years ago #

    Hi, I have a site with two Post Types, each have their own search boxes which filter search results to a specific post type.

    On my search.php page, I'd like to be able to extract which Post Type my results are filtered to.

    How can I do this?

    The URL of my search results looks like this:


    Any help would be really appreciated.

  2. Mav3000
    Posted 4 years ago #

    I've solved this one myself by searching for similar answers.

    I came across this thread:


    Where the answer lies in:

    	$post_type = get_post_type( $post );
    	if ( $post_type == 'posttype1' ) { ?>
    	<p>The Post Type is Type 1!</p>
    <?php } else if ( $post_type == 'posttype2' ) { ?>
    	<p>The Post Type is Type 2!</p>
    <?php } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic