You should use ‘post_type_link’ hook
and register post type ‘project’ with (‘with_front’ => true) parameters
'rewrite' => array('slug' => $slug, "with_front" => true),
==================================or=====================================
add_rewrite_rule('^project/([0-9a-z]+)/?$', 'index.php?project=$matches[1]', 'top');
====================================================================
function post_type_link_hook($link, $post) {
add_rewrite_tag('%url_id%','([^&]+)');
if ('projects' == get_post_type($post)) {
$urlId = get_post_meta($post->ID, 'url_id', true);
//Lets go to get the parent cartoon-series name
return str_replace('%url_id%', $urlId, $link);
}
return $link;
}
add_filter('post_type_link', 'post_type_link_hook', 10, 2);
Related Posts:
- Adding meta values to permalink
- Rewrite custom post type url’s adding meta box values
- Create additional short URL with custom field and 301 redirect
- copy attachments to another post type and change attachment url
- Using a custom field value to redirect away from a 404 page
- How can I use get_post_meta with add_rewrite_rule to build custom permalinks?
- Multiple URLS per post non-ascii
- URL Rewrite fires when retrieving a custom value?
- Pass PHP through redirect and custom fields
- Rewrite Custom Fields url
- Multiple permalinks for a single post from custom field
- Where are custom field values stored in the database
- Using TinyMce with textareas in meta boxes on custom post types
- How can I fetch CSS from JSON WP REST API response
- ACF – get_field() using ‘option’ as post_id not working
- Why does wordpress still strip my query var?
- How to set a default meta value for custom field
- Populating meta box with select-list of existing posts, and assigning it to custom post types
- Create meta boxes that don’t show in custom fields
- Rewrite Rule for Post “Subpage”, with pagination
- How To Create a Metabox of HTML Content with Instructions For Editors When Editing a Post or Page?
- wp_editor in add_meta_boxes does not show gallery
- Calling Specific Pages with wp query Part II
- How do I assign this filter to a variable? (Appending php & markup to the_content)
- add_rewrite_rule not registering on Multisite
- Copying Custom Meta Values from existing post to a duplicate post
- Deleting a custom field field
- custom field to always to .get_the_title()?
- Displaying posts with only upcoming dates according their custom field date value
- How to filter a dd/mm/yyyy date from a custom field in a query
- How can I rewrite a plugin generated URL?
- How do I add custom_meta_box_id’s value?
- Get a post_id where meta_value equals something in a serialized meta_value field
- List posts with common custom field value
- Importing users to Buddypress with custom fields
- Including Database Generated Pages in Site Search [closed]
- Is it bad to use a lot of Custom Meta Fields?
- How to get customfield value by woocommerce product ID
- How to save media files under custom folder without changing wp-config.php or changing media settings
- How can I sort homepage by a meta value?
- Audio player shortcode not showing up when using variable
- Custom Fields – Taller editing area
- How to add Advenced Custom Fields In Single Post
- Changes in permalink structure in WordPress and how to apply to in-site links
- Get updated meta value after post update or published (custom post type) using hook
- Custom permalink leads to index page
- custom-meta-box checkboxes from loop won’t save
- Custom dropdown field added to media gallery; how to get it to save properly?
- Uploading PDF using Media Uploader
- Rewrites rules disappear after a while
- Correct syntax for retrieving custom field in CPT
- $TBA Getting Translated to $0 (Custom Fields)
- How Do I Display A Custom Field In The Sidebar Of All My Pages?
- Hide text if one custom field out of two is empty [closed]
- Echo the custom field value from the latest post from the ‘video’ post format?
- Custom Field – Do Not Show if Value is Empty?
- What’s the best way to implement custom widgets on a per post basis?
- Displaying Meta-Box Data Properly
- wp custom field date format compare
- Order custom post type posts by custom field with pretty URL
- frontend submit post jQuery clone row won’t save
- WordPress simple Url Rewrite
- Include one custom field in search results
- Custom search SQL Query to add custom field in result
- Search Results Page – Displaying Custom Meta Fields
- Can wp_insert_post_data filter be used to save custom field data?
- Interrogate a page within a loop to check template type or custom meta data (Pages vs Posts)
- using advanced custom field to control css hover color
- Custom Field data only shows after manual post update
- Custom field Search with Relavanssi
- How to exclude custom fields from search queries?
- Add Custom Fields After Page Title
- Footnotes in custom fields
- How to show content of custom fields in search results?
- Rewrite custom taxonomy slug – but only parent items
- simple fields plugin custom query
- Multiple Taxonomy Items for Separate URLs
- Set class if a meta value is set within post archive
- Rewrite WordPress Url from root to subfolder without moving files
- Filtering posts by ACF meta query
- checking liked user in wordpress rest api
- How to display selected option from dropdown list in a metabox
- URL Rewrite and Archive Template Files – Post Type vs. Taxonomy
- what would be a good example of a php dynamic code to display contents of textarea?
- Get file size from ACF repeater field
- Append custom field items to content from plugin
- Query postmeta values, and return multiple post_titles for common meta value
- add_rewrite Rule
- Set Value To Custom Field While Submit
- Custom Field: Display only if a specific key is selected outside the loop
- Show or hide lang=”ur” in main element
- How to use a custom field for search engine optimization
- Fetch data from a WP page with same name as current username
- Getting content from custom fields of different pages on a single page
- How to get the value of particular get $meta value in wordpress
- custom field as a boolean with a checkbox?
- Hiding custom fields when content is empty [closed]
- Website that sells statistics
- Extract array from custom field
- Search for meta_query does not return any result if combined with title