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
- Get The Post Type A Taxonomy Is Attached To
- Custom Post type & Taxonomy URL structure
- Check if a custom taxonomy archive page is being displayed
- How to limit the number of terms (terms acts like categories)
- Displaying Posts Related to Other Posts by a Taxonomy Term?
- Separating Search Results By Post Type
- Add custom taxonomy to custom post type
- How do I add a custom post type to the Featured Content in twenty fourteen theme?
- Ajax filter with custom taxonomies
- Is there An Input Checkbox Option That Works like `wp_dropdown_categories()` To Use In A WP Search Form?
- Adding Custom Taxonomy Archive Link to Nav Menu Shows Up As (Invalid)
- How to dynamically build a multiple taxonomy query loop within a post type’s single loop?
- CPT Search Form with Taxonomy filter & Or
- Weird problem happening with custom taxonmy when creating/updating posts
- How To Create A Custom Taxonomy 404 Page
- $wpdb: Counting posts corresponding to 3 terms in 3 different taxonomies
- Overriding taxonomy and custom post type
- Best way to save horoscope data
- How do I move/order posts with a tag to the end?
- Get taxonomy values based on wp_query results
- Ajax Custom Post Filter is not filtering
- Need Output Custom Taxonomy from Custom Post Type
- Display all taxonomy terms, add class if term applies to current post
- Custom WP Query on custom meta and sort by multiple meta keys value
- How to display Custom Taxonomy under Custom Admin Menu?
- Custom Post Type + Categories
- Is it possible to use have_posts function to list custom post type posts inside a category?
- Including taxonomy term before post type breaks top level pages
- Correct procedure for advanced permalinks
- Permalinks: custom post type -> custom taxonomy -> post
- How to get the intersection of two terms both from different custom taxonomies
- Add Custom Post Type of specific Custom Taxonomy to regularly blog loop
- Custom taxonomy and post type with same slug
- WordPress Custom Post Type – show only certain posts that have specific taxonomy set
- Should I use custom taxonomies or not?
- Attaching a Custom Taxonomy to Posts?
- display custom taxonomies limited to custom post type?
- Category Search / Custom Post Type search on my website. Custom Post Types that are “page-like”?
- I am trying to get cutom post cout by month of current taxonmy term
- Custom Post Type and Taxonomy Loop Output Is Wrong
- Nested Custom Taxonomies | Incorrect posts when querying
- Commas not displaying in implode
- add custom tags for custom post type in wordpress
- “Cannot redeclare cpt_reg_tax()” because of functions.php
- custom taxonomy listing returns no posts
- Writing a custom Glossary plugin
- Rename existing cpt and taxonomy with new textdomain
- Custom front-end form for adding post – Category problem
- i want to send email to user when the custom taxonomy is changed
- How to show Custom Post Types under Taxonomy in a new WordPress page template?
- Issues with static pages redirecting towards home.php
- Displaying all posts by category and showing content on click
- Store a value in global scope after init hook is fired
- Custom post type and custom taxonomy key lenght & query performance
- Change the term based on the value of a $variable using wp_update_post in submitting a form
- Dropwdown: Get taxonomy terms from posts that share preselected terms from 3 other taxonomies
- Order posts by meta value hiding posts instead of re-ordering
- Custom permalink with custom taxonomies for custom post type
- Best Plugins for Complex Index of Resources [closed]
- Looping through custom taxonomy in one template
- Change the url of a custom post type to include taxonomy
- How to display all custom fields associated with a post type – IN THE ADMIN AREA?
- Query Posts with Custom Taxonomy from a Custom Post Type
- How to show a custom taxonomy using a custom template
- Custom Post Types in plugins?
- Custom term link return 404 error
- Remove slug from Custom Category Permalink + dual-category permalinks
- Display associated taxonomy child name on single CPT page
- Custom Post Type to Plugin
- Woocommerce product page is not showing custom css [closed]