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
- Adding ‘menu order’ column to custom post type admin screen
- How to Add Custom Fields to a Custom Post Type?
- Do_Shortcode not working for Embed
- Display custom post type and custom fields within a Bootstrap Carousel
- how to filter by last name for custom post
- Search that will look in custom field, post title and post content
- clients list using wordpress
- Order Posts by Taxonomy and Meta Value
- How to do a custom bookmarks post type?
- How do I add media to a custom post type?
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- add_meta_box: Datepicker like the one for postdate?
- query order by date on custom type: wrong order
- Taxonomy list. Order by a specific custom post type count
- Custom field losing p tags on display
- Using posts and postmeta table to store custom Address Book Plugin data
- Custom Post Type rewrite rules not working, how to alter the rewrite order?
- Frontend posting – everything saves other than checkboxes?
- Query Custom Post Types by date (custom field) range
- handling csv data with a custom post type
- Custom fields in Permalinks?
- query posts and custom post type with meta key
- Dynamically add / duplicate custom meta in custom post types
- Custom Post type and Custom Field WP_Query
- Adding Show Less/More link to Custom Post Meta
- Remove url rewrites for registered taxonomies
- Sorting custom post type columns with external data and without meta values
- Display posts from Custom Post Type in category page on front-end
- Give a permalink to Custom Post Types without title
- Cannot add custom field to “orderby” parameter in Rest API
- Custom post type + category archive page
- How do I change the custom taxonomy slug to be the same as the custom post type slug?
- Tracking changes in admin-page so user gets warning when leaving the page
- How to order and group custom post type posts by year and month
- How to Create a WordPress Plugin With Custom Post Type/Custom Field Features?
- How to integrate a form (Ninja Form or Contact Form 7) with Custom Post Types?
- First custom field value (out of several) displayed twice after query
- Multiple Frontend Filters Using Advanced Custom Fields
- Make custom post types and pages place nice, re: rewrite
- Use date in the URL of custom post type
- Add parent post to Custom Post Type [closed]
- Archive not sorting correctly
- Add custom attributes to a post
- Get post content from another section in custom single page
- Modify Posts from Custom_Post_Type within the plugin
- How to convert custom fields to content
- Group by custom field value (start and end times)
- Variable Products as custom post types
- updating one custom meta field only
- Confusion about how to use Custom Post Types, Custom Taxonomy or Category?
- Displaying Posts Using a Custom Query with a Custom Field and a term_id
- Create list from custom field comma separated values
- Having a repeating custom field in admin custom post type, what I’d go better with, for DB’s sake? ACF repeater or query a different post type?
- Create an user checklist system for a course plateform using ACF Pro and ACF Extended
- wp rest api orderby field in a custom table
- multiple URLS for the same page
- Auto update publish date of CPT Post if default post custom field value match to cpt post CF Value
- WP_Query get always custom post_type for first
- Category permalinks don’t work even after flushing
- Post Click Redirect to Custom URL instead of Single Post Page
- wp_insert_post deleting previous post custom meta
- Show posts from WP Custom Post Type selected from a field in a metabox
- meta query multiple values for the same key
- Custom post types – meta_query: search lesson which starts sooner
- Wp Query sort order from custom MetaBox
- Automatically convert standard posts with custom fields to custom post types
- Importing URLs of Audio Enclosures
- page not found for example.com/custom-post-name
- Retrieving custom post type fields without a post
- custom fields not showing before get_header
- Rewrite for custom type and custom taxonomy
- pre_get_posts with multiple post types AND a meta_key
- Search form to find custom meta box generated data
- Display Custom Post if custom field is marked
- predefined custom field on registration page
- Why won’t this rewrite rule work?
- Show Custom Post Type taxonomy term that matches custom field
- Adding rewrite rules to Custom Post-type mixed with Taxonomy
- Select Menu for Custom post Type does not save
- Allow authors to create article image
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- Allow admin to determine the order of queries?
- Custom post type permalink structure
- Send email on creation of custom post type and use get_post_meta()
- WordPress does not show the custom fields box