Your code runs only on post type archive pages. Unless your home page is a post type archive (doubtful) this code won’t run.
Change this:
if ( is_main_query() && is_post_type_archive() ) {
To this:
if ( is_main_query() ) {
And see what happens. The code will execute on every main query — every page–, including your home page. You should see the results you want on that page, but you can’t leave it like that. You will have to alter the function to only run on the home page. Something like:
if ( is_main_query() && is_front_page() ) {
Or:
if ( is_main_query() && is_home() ) {
I am not sure which you need given the limited context provided by the question.
Related Posts:
- How to Add Custom Taxonomy To Woocommerce Plugin
- register_taxonomy with multiple object type and update_count_callback
- Maintaining WP_Query Relation Among CPT, Custom Taxonomy, Permalinks- CPT UI
- Randomly placed sticky custom posts complemented by blog posts
- Display custom taxonomy as dropdown list
- Best practice for adding posts in bulk
- Best action hook to create custom post and assign taxonomy terms to it on plugin activation?
- Set object terms not working on plugin activation
- how to add extra meta box or textarea into custom post types
- Show listings from Impress Listing plugin in random order using taxonomy and terms
- Why get_posts() not returning only selected category posts from Custom Post Type?
- Adding a custom post type taxonomy template in plugin
- limit value taxonomy based on previous taxonomy value wordpress
- Dynamic dropdown select values depending on other custom field value
- Metabox not show in categories custom post type cmb2
- How to change permalink to include custom post type
- Custom Post Archive is not working
- Show all tags on custom post type
- Getting only one post per category
- Multiple archives to display parent and subcategories content
- Is it possible to arrange Custom Post Types from CPTUI into a Folder?
- Filter Custom Post Type Posts by Taxonomy
- Insert custom taxonomy into category query
- CPT UI: Connect a custom post type to a custom post type
- Create Inclusions and exclusions
- Show custom taxonomy not in submenu
- How to Fix WordPress 500 Internal server error due to custom post type
- Plugin Error on activating
- Plugins for putting Custom Post Types into the Menu
- How to Create Short Code Using Custom Post type
- Prevent custom taxonomy from being added to admin menu?
- Add Tags to custom post type
- Querying Term Posts in Loop
- Custom taxonomy template for multiple custom post types
- Custom Taxonomy term archive template
- How can I filter by taxonomy on a custom post type’s page?
- Custom Post Types relationships
- Displaying Multiple Post types in Taxonomy
- Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
- Custom Post Types for Support Ticket plugin?
- custom taxonomy relationship
- Can custom taxonomies items have attached properties?
- How many Custom Post Types to register?
- how can i get posts from custom post type particular taxonomy category
- Associate custom post types with normal posts
- Problem with custom post types, taxonomy and permalinks
- How to create new category for custom post type?
- WP 3.0.5 – Custom posts matching 2 taxonomies
- Custom Post Type Loop within Shortcode
- How can you handle rewrite rules for custom post types with option to filter on custom taxonomy terms?
- Custom Post Type – Display Categories & Tags In Dashboard list
- Fetch taxonomies by custom post type id array
- How to retrieve category NAME instead of ID in a function with a taxonomy custom field?
- I can’t choose the custom taxonomy in my custom post type on Gutenberg
- “add_post_type_support” with Custom Post Type & ACF
- How to check the terms in single custom post type template
- Weird problem happening with custom taxonmy when creating/updating posts
- get_terms showing all categories instead of the ones assigned to a specific post
- Shortcode insertion in tab
- How can I move a custom taxonomy and its data from one post type to another?
- Group custom posts by custom taxonomy names
- How To Create A Custom Taxonomy 404 Page
- Custom page template for category taxonomy
- Display Posts in Custom Post Types Timber
- How to Get Current Custom Post Type Selected Taxonomy Term (Not All Terms)
- Permalinks not working for custom taxonomy on custom post type
- Add/Remove current_page_parent class
- Can’t get order_by meta_value_num to work properly
- How to quickly reorder posts in the admin panel that will persist for the wp-api
- Permalink Structure CPT With Custom Taxonomy Fails
- How can i skip same post from taxonomy term?
- Parent & Child Taxonomy slugs in custom post permalink
- get_template_part for each level of taxonomy term
- Display custom post type in hierarchical order with get_terms
- Add CPT as subpage under custom page
- Filter by custom taxonomy slug on a custom post type
- Create 3 Level Relations with ACF and WordPress
- Conditionally custom post type url rewrite
- Displaying a custom post types custom taxonomy value?
- Repeating posts when paginating random posts
- Insert HTML inside link in a walker
- get_the_terms return only last term
- How do I make a custom taxonomy for a CPT appear inbetween title and editor boxes?
- Normal pages as children of my Custom Post Type
- Custom Post Types and independent Categories – complex Taxonomy
- Custom post type and taxonomy slug issue
- WooCommerce product search titles only
- check if post title in a custom post type exists in page
- Taxonomy Archive: Display only one post per term from separate custom taxonomy
- Change Permalink Structure for Tag.php template
- $wpdb: Counting posts corresponding to 3 terms in 3 different taxonomies
- Does WordPress limit the length of slug names for Post Meta or Terms?
- Custom Taxonomy Permalinks Redirection
- Only show posts from a certain category?
- Query Multiple Taxominies Across Multiple Post type’s
- WordPress as Wishlist Application
- Use different taxonomies in different custom post types’ permalinks?
- Should I use custom taxonomy or custom post type
- Podcast Guest List
- Pagination : How to remove /page/x/ after a ‘POST’ action on a form returning to page 1