Changing a query for the page
post type via pre_get_posts
is a bit tricky, and maybe not worth the potential issues involved. If you inspect the generated SQL, it’s looking for your requested pagename in the question
post type, which is why you get the 404.
The solution is to delete the page, so WordPress will load a post type archive by default, or keep the page and use WP_Query
within the template to load the custom posts.
Related Posts:
- Prevent pre_get_posts filter on specific post type
- How to put custom post types on front page
- Include post id[s] into WP_Query()
- How Do I Use WP_Query to Run This Database Query as Search Result?
- Can’t sort order of wp_query with 2 meta keys
- Display all Posts and only certain Custom Post Types with meta fields
- How to query for posts (hierarchical custom post type) that have children but are NOT top level?
- Query to Exclude Child Pages from Custom Post Type Archive
- pre_get_posts gives 404 error on Custom Post
- Custom Post Type shows pagination (w/404) or posts_per_page query, but not both
- How do I sort post listing by child post count?
- Query all posts where a meta key does not exist
- Exclude a category from WP_Query
- Single loop for wp_query and wp_user_query
- query multiple taxonomies
- Custom Post Type, WP_Query and ‘orderby’
- Pre get posts for single post
- Syntax to get the Nth item in a list of custom post types?
- Grab 5 latest posts from custom post type ‘announcements’
- WP_Query to loop a Custom Field, Custom Post Types do not show
- Order posts by (hierarchical custom) taxonomy terms and term children
- Sorting a list of posts displayed under a list of associated terms (which should be sorted without initial articles)
- Query not returning CPT posts
- Custom Taxonomy and tax_query Issue?
- Unable to display multiple post types in same query (WPML WP_Query)
- How to use custom post type APIs, but use a different db table
- Select menu should display categories and the item’s depth
- Custom Post Order for a Custom Post Type
- Lists Posts from CPT that match the Title of the Page
- Filtering by Post Meta Custom Fields – Performance
- Returning a list of custom post types excluding those without a specific meta_value
- query private custom post type
- Query custom post type with tags
- Randomize Posts. Skip the first post in ascending order
- Pagination for Custom Taxonomy Page [duplicate]
- Custom loop with multiple taxonomy queries
- Isotope Filtering with Bootstrap Tabs – Custom Post Type Query Loop in each Tab (Have to click twice to filter)
- creat filter with wp_query
- How to do WP_Query with two meta fields with orderby clause
- Get Posts by multiple custom fields is not working
- Custom query at top of archive search page, arguments are overridden
- How to have this permalink structure: post_type/postname/custom_inner_page
- Sort entries by date mixing two post types
- custom post type search by reference id
- Showing specific post in order of array wp_query
- Print current post category during WP_Query
- Main menu not appearing in custom post type archive
- Multiple Custom Post Type queries, how to DRY it up
- Custom WP_Query always respond with 200 status even when no entry
- WPDB for post count on post
- post_per_page ignored in WP_Query
- WP_Query parameter conflict
- Retrieving meta-box from a custom-post-type
- Cannot get custom post
- Custom post type and standard post not displaying or working
- Display custom post type for specific user
- Get all post from a post type
- Trying to add a class to post links
- A faster way to query custom post types with multiple conditions?
- List all Custom Post Type posts excluding certain Taxnomy term
- WP_Query: Posts within category OR custom post type
- Two queries – one with checkbox ticked, one without – comparing meta_query
- posts_per_page in custom WP_Query does not override “Reading” settings?
- WP Query from two Custom Post type fields as statement
- Display Parent-Child Posts in specific order by comparing IDs in array
- Display post count for a specific month
- WP_query has incorrect wp_posts.post_name = ‘asc’ when I have custom post type called ‘order’
- Randomizing WordPress Custom Post Type Sorting Through Them Without Page Refresh
- Order posts alphabetically with numbers but some of the posts has numbers in the title
- How to output custom post type title on custom page with category next to it?
- How to sort by multiple values in a nested WP_Query
- SEARCH QUERIES – REVERSE OUTPUT
- WP_Query to display number of custom post type filtered (order by) taxonomy
- post_type incorrect for custom post type
- Live search by custom tag
- How to get the posts that my following users are liked?
- Only show categories that have posts within custom post type
- SQL LIKE in WP_Query
- How can you use a page for a custom post type?
- Display all Custom taxonomy terms and their relevant custom posts
- WP Query with multiple post types ordered by custom meta date then published date
- CPT Efficient way to display posts from different categories with custom query
- How To Loop Through list with Custom Post Types
- CPT or Custom Table for Repository of Serial Numbers
- Use Tags to Query Associated Multiple Posts and Get The Average Of Custom Field Values
- Custom Post Type + Category archive
- Values inside a custom field to determine which category posts to display
- Using $seed on a custom post type for randomly displayed posts
- WP_Query get posts where post_name is empty
- Pop up showing same content on all posts display.
- Custom post-type’s pagination not working in category.php
- Listing all custom post types using a specific term on the said term’s template page, in groups
- Querying meta values within an array
- Count of posts with meta_key filled in?
- Archive page – problem with pagination
- Are custom posts included when getting a categories’ posts?
- Query order by meta value force specific tag first
- WordPress custom field sorting, weird behavior: the latest post is at the end
- Default WordPress Query for a Specific Custom Post Type URL
- Dynamically count the number of custom post types associated to a custom taxonomy