The $rewrite
parameter of register_post_type()
accepts either a boolean or an array. We can overwrite the existing value of $rewrite
with the array of our desired settings:
function overwrite_gallery_slug( $args, $post_type ) {
if ( $post_type === 'gallery') {
$args['rewrite'] = array (
'slug' => 'team-murray',
'with_front' => false,
);
}
return $args;
}
add_filter( 'register_post_type_args', 'overwrite_gallery_slug', 10, 2 );
Remember to flush permalinks after implementing this code.
Related Posts:
- Why does my custom WP role need edit_posts to edit images?
- How to pass URL parameters for advanced taxonomy queries with multiple terms for one custom taxonomy
- How to filter by custom post type on Gutenberg “Latest Posts’ block
- How can I list all the categories under a Custom Post Type (taxonomy)?
- Multisite wide post type?
- How do I remove all the metaboxes for a custom post type?
- How to list/show all custom post types regardless of category?
- Remove CPT slug from URL
- How to sort a table of custom posts by column containing custom field
- I have a CPT that have menu_order enabled, how can I make the menu_order values unique so it won’t have duplicates
- Add pre-existing meta box to new custom post type
- WordPress metabox file upload in custom post [duplicate]
- tags & categories with custom post type
- Querying Posts by Taxonomy From Alternate Network Site
- working Custom Post Type and Widget code no longer works when moved from functions.php to plugin
- Archive filter disappears on no results?
- How do I add a custom button to my “edit” list? ( edit.php?post_type= ) beside “Add New”
- How do I display custom post types through a common taxonomy?
- How do you remove slug altogether from custom post type?
- Add custom post type to Backbone collections
- how to add extra meta box or textarea into custom post types
- How can I show a custom post type for users in the authors.php file?
- Prevent custom taxonomy from being added to admin menu?
- How to remove slugs from multiple custom post types
- Very Slow Page – How to Optimize # of Queries?
- WordPress Genesis custom taxonomy archive shows 3 repeats of each post
- Custom taxonomy in URL showing 404
- Problem with WordPress query on page using custom fields
- Query posts and custom post types within the same category
- Rewrite slug of custom post type to include post-id
- Display not found page 404 on specific Post Type
- Display upcoming Events for next 7 Days
- Orderby CPT custom fields not working
- How to duplicate entire custom post type
- How to sort custom columns for custom post type without meta query and pre_get_posts?
- How Can I Change the Custom Post Type Slug to the Taxonomy Slug in the URL?
- Allow Editor to view/modify a custom post type
- Custom post type permalink tag 404
- How to get list of taxonomy slugs ordered parents>childs?
- How can I list Custom Post Types created with the Types plugin under categories?
- Show child custom post types on single-{parent}.php?
- Custom Post Meta from custom metaboxes is randomly being deleted
- Is there any way to get list of all possible filter hooks for all post types?
- Why won’t this jQuery code work?
- Custom post_type search pages
- A Collection of Custom Post Types Displayed In a Submenu
- writing posts in indian regional language (Punjabi)
- Template for custom post type when taxonomy is in the URL
- Why WordPress is picking archive.php instead of page.php?
- Custom Post Type posts, conflict with posts after add_rewrite_rule to top
- Get data from PHP to JavaScript to set position of each post on front page
- Child theme blocks post from publishing [closed]
- Targeting child pages of custom post types using function?
- Query custom post types & Taxonomies and list them in a table on a page
- How should i sort “Last Update” Custom Column?
- How to query for posts (hierarchical custom post type) that have children but are NOT top level?
- How to query custom post type by two terms?
- Make a page an archive of a custom post type
- Incorrect ordering of custom post type based on time
- Redirect to URL if x number of days passed
- How to controll the Posts post type and general wondering about WP data structure
- Make Next and Previous on single-$posttype.php use the same order as archive-$posttype.php
- Modifying search results based on post_type
- WordPress general content best pratices
- Posts 2 Posts plugin: best way to change connection field value?
- Stop displaying Permalink
- Auto Generate Post Title from 2 Custom Fields
- Enforcing a rigid reusable template structure for similar posts?
- Custom posts stopped working after moving to new domain
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- How can i redirect click to new admin page not to edit screen in post table
- How to convert Post Object Custom Field into Tags
- Shortcode and get_template_part
- Custom post pagination not working
- Two and more diffrent custom page type in one permalink
- Page as parent for CPT and other pages
- Duplicate posts in my custom loop
- How to display a custom post as a page (but unedited)?
- Set a static page as a user profile page?
- Why get_posts() returns empty array while I am trying to get posts from some specific taxonomies and work properly with others?
- Populate metabox dropdown with post title from another Custom Post Type (issues with wp_reset / global $post)
- How to keep a CPT stick to specific position?
- Meta box not saving
- Shortcode display CPT Query only showing 1 post?
- Default taxonomy ‘post_tag’ added to CPT managing by custom role : nothing in the metabox
- Query stopped working
- Strange behaviour using 3.8.1
- Setting a custom $query->query_vars[‘meta_key’] breaks the WordPress menu
- Filtering in admin broken for custom post type in 3.8.1?
- Get Registered Custom Post Type to get All Custom Taxonomies
- Custom pagination [duplicate]
- WordPress loop to pull 4 pages/posts by ID
- how to show perticular category posts in custome page
- Custom Post Types and 404 Pages
- Bulk update custom post types
- Display ONLY ONE $term (Out of 4 terms) from a Custom Taxonomy and CPT
- Adding a custom field after post title (ex.Example Title [30 Second Read])
- pre_get_posts causes Custom Posts appear under ‘Pages’ menu
- Assign a tag to custom post type using a query
- Categorizing Custom Posts in Bulk Based on Title