My search results show pages from both WordPress & woo-commerce. I want to show some specific product information in the search results that only products have. Normal WordPress pages do not have this meta information and the search page fails if there are WordPress pages in the results.

So I want to show different search information if the result refers to a wordpress page, or if the result is a woo-commerce page. I thought it would be as simple as using is_woocommerce() or is_product() on my searchloop.php but these codes refer to the search page itself, not the search results. Hence only is_search() will result in a positive result.

Is there a way to use conditional statements that apply to the search results?

1 Answer 1


Within the loop the best way to check if the result is a product would be to check the value of get_post_type():

if ( get_post_type() === 'product' ) {


As you say, is_woocommerce(), is_product() and is_search() are for checking which type of page is being viewed regardless of the current item in the loop.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.