&& is_post_type_archive('local-attractions')
is_post_type_archive isn’t set yet, WP is still deciding this, hence the call to pre
. Instead use:
_get_posts
&& $query->is_post_type_archive('local-attractions')
The same is true of any other is_
type methods, use the $query
object, else you might be asking these questions about a completely different query and getting confusing results
Related Posts:
- Excluding a Custom Post Type with a specific tag using pre_get_posts
- Custom Post Type shows pagination (w/404) or posts_per_page query, but not both
- How to remove custom post type archive
- How to use a custom post type archive as front page?
- Custom Post Type Archives by Year & Month?
- Get custom post type slug for an archive page
- Create a custom archive page for a custom post type in a plugin
- Custom Post Type Settings page, choose page to display archive
- Adding a menu item for a Custom Post Archive
- Custom Post Type Archive Page not showing
- Adding custom post type archives to a WordPress menu
- How to set a custom post type to have viewable future posts
- Custom Post Type Template – Archive
- Prevent pre_get_posts filter on specific post type
- Page Template as Custom Post Type Archive
- Custom post type yearly/ monthly archive permalinks
- Can’t get post id on page that is a custom post type archive
- Meta_Query as a way how to setup CPT permalinks – is it a good thing?
- $query->set in pre_get_posts is unintentionally affecting the backend
- How do you create an archive for a custom post type from a plugin?
- Proper way of making custom post type landing page or archive page
- Custom Post Type Archives by Date with Custom Permalink
- How to put custom post types on front page
- How to List All Custom Post Types Names (Not Posts)
- Add Custom Post Type to Current Query
- Change title in head on Archive page
- Custom Post Type Archives with 0 Posts Redirects as 404
- How to show more posts on an archive page?
- Include post id[s] into WP_Query()
- Pre get posts for single post
- How to filter custom post type archive by meta value
- What are the advantages of using a custom post type archive?
- Page is defaulting to archive page and not designated template
- custom post type archive page url to point to Page permalink
- “Edit” option for custom post types archive page
- How to get my Custom Post Type to display in Recent Posts using “pre_get_posts”
- Custom Post Type archive as front page
- Better to use a post type archive, page template, or shortcode for generating a highly configurable CPT archive?
- Get monthly archives for custom post type
- Is it possible to remove the posts_per_page limit on a specific post type?
- Add Settings to Custom Post Type
- Pre_get_posts Gives 404 on Custom Post Type
- Is it possible to have an index page for taxonomy term for each custom post type it is assigned to?
- Custom post type permalink structure with the category also acting as an archive
- How to get_queried_object on multiple objects?
- Custom Post Type Works but Still Shows “Page Not Found”
- Assign Page Template Within A Custom Post Type
- filter search result with custom post type meta key
- Custom Post Type / Taxonomy Slug / Post Title with post type archive
- Rewrite custom post type url’s adding meta box values
- Order posts by (hierarchical custom) taxonomy terms and term children
- I can’t set meta_key in my custom post type query
- Hide child term posts on parent term pages
- Posts per Page on custom Taxonomy Template
- Meta Query “IN” doesn’t work with ACF checkbox filter
- Compare 3 custom fields and sort by oldest
- Post type archive page not working
- Adding Sticky functionality to Custom Post Type Archives
- How Do I Use WP_Query to Run This Database Query as Search Result?
- paginate function in archive for custom-post-type
- Limiting number of custom posts shown on taxonomy page
- Adding custom post types to archive.php
- Custom Post Type – Archive page title
- Alphabetical sorting of custom post type – one letter per page
- List all posts in Custom Post Type but group dynamically by Custom Taxonomies
- Include custom post type in “all posts”
- Archive page for taxonomy of custom post type
- Add meta data to the custom post type ARCHIVES page
- Should I change these content meta types before building complex archive page?
- Can’t sort order of wp_query with 2 meta keys
- Sort custom post types by last name in the backend
- archive-{$post_type}.php not loading. instead the default archive.php loads
- Displaying custom post type on category pages but not on blog listings
- Getting taxonomy terms used by custom post type
- Custom post type archive sorted and grouped by date in post meta field
- Archive or taxonomy pages not working for custom post type
- Custom post type with tags
- Create Custom Post Type Archive Page with Sub Categories Navigation Sidebar
- Custom Post Type archive giving 404
- pre get posts changing the query
- How to create archive page for taxonomy terms within custom post type
- How to make an archive page displaying posts in a date range
- Categories and Tags not working!
- Custom taxonomy template not working with simple loop. Multiple CPT using the same taxonomy
- Display all Posts and only certain Custom Post Types with meta fields
- Building an Advanced Search (text, tags, category, custom fields) – Getting the wrong SQL query
- Using pre_get_posts to Filter Posts
- Custom query variable – get wordpress to redirect to nice permalink url
- WordPress custom post type archive with description
- Custom-post-type-archive: posts sorted/filtered by year?
- How to list custom post types?
- I am facing problem in my archive page , it is partially working
- add_rewrite_endpoint() and Custom Post Type Archive
- Custom post type archive page pagination
- Add the current menu item CSS class to a custom page type archive in WordPress menu
- Display Next/Prev when looping Custom post-types archive?
- Add custom post type archives to search results?
- Archive page for custom post type not working
- taxonomy template for custom post type the same as the archive
- Editable content on a Custom Archive page