Change Number of Posts Displaying on a Custom Post Type (CPT) Archive Page
To change the number of posts that appear in an archive page for a custom post type you can change the number using the pre_get_posts action with some passed in parameters. Normally the number of posts displayed per page is defaulted to the setting in the Dashboard Reading Settings > Blog pages show at most –…
Read MoreCompletely hide WooCommerce products from shop, product search and WordPress search
You can hide a WooCommerce product from the shop page and product search by choosing ‘Hidden’ in the ‘Catalog visibility’ options from the Publish metabox on a product page in the backend. This is good and it hides the product as advertised from the shop and product search results but the product is still visible…
Read MoreChange Amount of WooCommerce Products Displayed on Shop Page
WooCommerce displays by default 4 columns and 10 products per page in the shop or archive page – the products per page is based off the amount of post set to display in the WP Admin Dashboard > Reading – Blog pages show at most setting. Here is how you can change the amount of products…
Read MoreFiltering Posts with Custom Fields Using meta_query
You can further refine a list of posts by filtering any custom fields that the post has for a certain set of conditions, this is possible with WP_Meta_Query, which allows you to target custom fields as known as post meta. There are a couple of ways to use the WP_Meta Query class, the meta_query array is…
Read MoreHide a certain Category’s Posts from the Home/Blog page in WordPress
To hide a certain Category’s posts from the home or blog page you just need to know the category ID and then use a filter on the pre_get_posts hook to exclude those posts. To find the ID for the Category just go to the Category and hover over the edit button and the ID appears in the…
Read MoreHide Pages from Search Results in WordPress
In WordPress by default both posts and pages are included in the Search Results, you can remove pages or posts for that matter and also include custom post types by using the action hook pre_get_posts. In your functions.php add the appropriate snippet; To remove pages from the search results add in… To remove posts from the…
Read MoreShow Custom Post Types in Category Archive Page
By default WordPress custom post types do not appear in a category or tag archive page, to change this behaviour and display the custom post type you can add this filter/function to your themes functions.php file. function themeprefix_show_cpt_archives( $query ) { if( is_category() || is_tag() && empty( $query->query_vars[‘suppress_filters’] ) ) { $query->set( ‘post_type’, array( ‘post’, ‘nav_menu_item’, ‘custom-post-type-name’…
Read More