- What is_shop() Checks
- Syntax and Return Value
- When to Call is_shop()
- Example 1: Change Products Per Page on the Shop Only
- Example 2: Hide the Sorting Dropdown on the Shop
- Common Mistakes
- Related WooCommerce Conditional Tags
- FAQs About is_shop()
- Does is_shop() return true on a single product page?
- Does is_shop() return true on product category pages?
- Why does is_shop() return false inside pre_get_posts?
- Can I use is_shop() in functions.php?
- Conclusion
The shop page is where most product browsing starts. Store owners often want to change its layout, its product count, or its sorting, and they want those changes to stop at the shop.
The woocommerce is_shop function, written as is_shop(), tells you when the current request is the shop. This guide explains what it matches, the one timing trap that catches most developers, and two examples you can use right away.
What is_shop() Checks
is_shop() is a WooCommerce conditional tag. It returns true on two kinds of page: the shop page you set in WooCommerce settings, and the product archive that lists all products.
Product category and tag pages are separate. is_shop() returns false on them. For those, use is_product_category() or is_product_taxonomy().
Syntax and Return Value
- Arguments: none.
- Return value:
trueon the shop page or product archive, otherwisefalse. - Where to use it: inside hooks that run after the main query is set up.
When to Call is_shop()
The main query sets the shop flags, and conditional tags read those flags. Before wp runs, they are not reliable.
The trap is pre_get_posts. That hook runs before the query, so is_shop() can return false there even on the shop. Inside pre_get_posts, check the query object instead, for example $query->is_post_type_archive( 'product' ). For the examples below, use wp or a filter that runs during the loop.
Hooks that work well:
- wp runs after the main query is ready.
- loop_shop_per_page runs while the shop loop is built, so is_shop() is reliable there.
- woocommerce_before_shop_loop runs just before the products print.
Tip: If a shop rule works on the archive but not on a shop page built with a static page, the page may be using a different query. Test both URLs after you add the code.
Example 1: Change Products Per Page on the Shop Only
WooCommerce uses the loop_shop_per_page filter for the number of products in each shop grid. Wrapping it in is_shop() limits the change to the shop page and product archive.
<?php
add_filter( 'loop_shop_per_page', 'my_shop_products_per_page', 20 );
function my_shop_products_per_page( $per_page ) {
if ( is_shop() ) {
return 12;
}
return $per_page;
}The third argument, 20, is the priority. Keep the filter’s default output for other archives, such as category pages, by returning the original value.
Example 2: Hide the Sorting Dropdown on the Shop
Some stores want a cleaner shop header with no sorting dropdown. The dropdown is added by the woocommerce_catalog_ordering function at priority 30, so you can remove it inside a wp callback that checks is_shop().
<?php
add_action( 'wp', 'my_shop_hide_ordering' );
function my_shop_hide_ordering() {
if ( ! is_shop() ) {
return;
}
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
}Removing the dropdown does not disable sorting in the URL. Customers who open a sorted link still see the sorted results.
Common Mistakes
- Checking is_shop() in pre_get_posts. The main query flags are not set yet. Check the query object instead.
- Expecting it on category pages. Category and tag archives are separate. Use the taxonomy checks.
- Calling it in init or at file load. The function returns false before the query is ready.
- Forgetting the static shop page. If you set a static page as the shop, test that page and the archive, since the query may differ.
Related WooCommerce Conditional Tags
The shop check often pairs with product rules. If you want to shape what each product card shows, read the guide on the single product summary hook. If you want to move the shop to a different URL, see how to change the WooCommerce shop URL. The other page checks are covered in the guides on is_cart(), is_checkout(), is_account_page(), and is_product().
FAQs About is_shop()
Does is_shop() return true on a single product page?
No. A single product page is a different request. Use is_product() for single products.
Does is_shop() return true on product category pages?
No. Category pages are taxonomy archives. Use is_product_category() for those pages.
Why does is_shop() return false inside pre_get_posts?
The main query flags are set after pre_get_posts runs. Check the query object, such as $query->is_post_type_archive( ‘product’ ), inside that hook.
Can I use is_shop() in functions.php?
You can call it inside a hook that runs after the main query is ready, such as wp. A direct call at file load returns false.
Conclusion
is_shop() is the right check for the shop page and the product archive. Use it inside wp or a shop filter, and check the query object if you work in pre_get_posts.
If you want a shop layout or product listing built for your store, hire a WooCommerce developer or send your requirements through the application form.
