If your post type slug is placement
, and you set has_archive
to true
, then the archive WordPress generates is at /placement/
. Set has_archive
to placements
instead and let WordPress add the rewrite rules (which will also handle pagination properly).
Then, to order by your meta key, add a function hooked to pre_get_posts
, check if the query is_main_query()
and is_post_type_archive( 'placement' )
, then set your meta_query
parameters there.
Related Posts:
- Adding meta values to permalink
- Rewrite custom post type url’s adding meta box values
- List upcoming events, ordered by date in a custom field
- Display custom post types with custom date field value (before today) & order by custom date field
- How can I use get_post_meta with add_rewrite_rule to build custom permalinks?
- Order Custom Post Type by Custom Field Value
- Add a custom meta box for client to order CPT posts how they want
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- Filtered by a custom field, ordered by another
- Orderby if between two meta fields
- What’s the most efficient way to get two queries based on an if statement?
- Show first posts with custom field not empty and order all by title
- How to display custom post type ordered by a custom field date
- Order Custom Posts by Several Fields
- 404 on Pages for Custom Post Type & Query_Posts
- Using custom field content as expression in IF statement [closed]
- Meta Query Not Returning Output Despite Having Matching Values
- How to create a custom post type with additional fields?
- Callback to custom field is not working in WordPress REST API
- Meta Query Filtering not working on Custom Meta Box using Radio Buttons
- Including metaboxes from custom post types in global search — continued
- ACF From & To Date Validations
- How do I set all of a particular post meta to a value within the custom post type I’m in?
- Query Multiple Custom Posts by Custom Fields
- Customize Custom Post Type URL
- Show image gallery from a custom field
- Using advanced custom fields from one custom post type in another custom post type / using nested shortcodes
- Dynamic dropdown select values depending on other custom field value
- How to render a custom post type template with custom fields using shortcode
- How do I change the custom taxonomy slug to be the same as the custom post type slug?
- Disable saving posts as draft (make all posts mandatory regardless of the post status)
- Grouping metadatas into one
- Tracking changes in admin-page so user gets warning when leaving the page
- filter custom post in rest api with custom function
- Get Posts by multiple custom fields is not working
- Woocommerce custom field search in custom post type [closed]
- Add custom field in comments form
- How to order and group custom post type posts by year and month
- Custom taxonomy rewrite with query var returns %2F in URL
- Custom Fields for Custom Post [closed]
- WP Rewrite Rule Issue while using Custom post type & taxonomy
- Custom Permalinks with CPT and Hierarchical Taxonomies
- Filter custom post types by a field value
- Displaying All Posts of a Custom Post Type in WordPress Multisite Backend
- Rewrites/query for multiple hierarchical custom post types
- cpt and page sharing same base permalink
- Repeatable Fields Metabox with Textarea (or wp_editor)
- How to use TinyMCE Editor for one of my custom post meta field?
- Custom REST endpoints for a custom post type with custom fields
- Hide or disallow default custom post type url?
- A case for Hierarchical Custom Posts
- CPT Template Not Showing – Getting 404
- How to Create a WordPress Plugin With Custom Post Type/Custom Field Features?
- Hierarchy and access control for Custom Post Types (CPT)
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- Post Type rewrite rule to point to custom Page/template
- How to integrate a form (Ninja Form or Contact Form 7) with Custom Post Types?
- Rewrite CPT child page URL to support query var
- First custom field value (out of several) displayed twice after query
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Meta Query posts not showing on ending date of custom field
- Get the taxonomy of a post hierarchically
- Canonical url differs from custom post type archive URLs
- Cannot save CPT meta box
- Change sort order when using ‘orderby’ => ‘type’
- Cross reference custom post types
- Adding Page Templates to post but it ignored it
- Display Woocommerce Orders for specific author [closed]
- Default post tab showing twice in admin bar
- Include related custom fields from one post type in another post type’s JSON feed
- How to get list of taxonomy slugs ordered parents>childs?
- Custom post type permalink returns 404
- Admin Custom Meta Box – Pull Last 5 Posts from Custom Post Type
- remove base slug from hierarchical custom post type
- frontend image post uploader
- Rewrite Endpoints and CPTs – How to use in a plugin
- Permalink structure with custom taxonomies and custom post type like /parent-tax/child-tax/custom-post-type-name (with no base name)
- Is there any way to add a “custom field” to the CPT archive page?
- Ordering custom post type by multiple custom fields
- How to Output which matched meta_keys were found from custom_type_posts?
- Multiple Frontend Filters Using Advanced Custom Fields
- Make custom post types and pages place nice, re: rewrite
- Custom Post Fields at the beginning of a Custom Permalink
- add_rewrite_rule and passing variables for custom post types
- Flush Rewrite Rules when new site is created on network
- Integrate Custom Post Type Events into Calendar
- Possible to filter custom post type with multiple meta data?
- Pretty URLs and custom post types
- Use date in the URL of custom post type
- Get url.com/post_type/taxonomy/term work!
- Specific routing for CPT
- Hierarchical custom fields
- How to get a custom field value of a custom post?
- Fields for different parts of a page
- Is it possible to activate customfield ‘text description’ upon activating the customfield ‘checkbox’?
- Facebook social publisher and custom post type fields [closed]
- How to display products name in a non-alphabetical order, in a custom field (taxonomy)?
- Displaying custom field according to date
- Displaying and searching Custom Posts
- Importing Data from a Non-WordPress database, into WP