Mav3000
Member
Posted 5 months 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:
http://www.domain.com/?s=mysearchtext&post_type=mypostype
Any help would be really appreciated.
Mav3000
Member
Posted 5 months ago #
I've solved this one myself by searching for similar answers.
I came across this thread:
http://wordpress.org/support/topic/problems-with-is_post_type-perhaps-it-is-a-bug?replies=25
Where the answer lies in:
<?php
$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 } ?>