This will do.
The slug is saved on the wp_posts while custom fields are on the wp_posts_meta. If you want to make it like that you can use an action hook on save_post that will get the value of the custom fields and saves it as the post slug.
Here is the code
add_action('save_post', 'set_slug');
function set_slug($post_id){
$new_slug = get_post_meta($post_id,'custom-slug', true);
$post_args = array(
'ID' => $post_id,
'post_name' => $new_slug,
);
wp_update_post($post_args);
}
Related Posts:
- Dynamic Endpoints
- How to add custom rewrite rule to .htaccess?
- How do I remove a rewrite rule?
- Problem with add_rewrite_rule and pagination (paged and page query_vars)
- How to change default page slug?
- Disable wordpress pagination URL rewrite for specific page
- Rewrite url for custom post type
- add_query_vars and add_rewrite_rules
- rewrite_rule() not preserving the query string
- Need help with rewrite_rules_array
- Mod_rewrite delete parameter in 301 Redirect
- add_rewrite_rule not working for page var
- Custom rewrite rules are sending everything to index.php
- WordPress Network on IIS7/SQL Server – Rewrite Issues
- Custom comments
- Adding the amp url prefix to the beginning
- add_rewrite_rule again
- Tricky URL rewrite with custom values in url
- Add rewrite rule to call front-page.php?
- Add a query string to ALL links on site
- How make a multi language routes, with rewrite rules or rewrite endpoints?
- Evaluating a external rewrite rule before internal wordpress rewrite rule
- Add rewrite rule for rewrite endpoint
- Having trouble with using add_rewrite_rule and pagination
- Rewriting rules: difference between ‘init’, ‘rewrite_rules_array’, ‘generate_rewrite_rules’?
- WordPress rewrite rules for state and city
- Multiple Permalinks for Same Post
- Single Redirection Rule for Pages and Archive links
- Remove “/page/1” from the URL
- hard flush_rewrite_rules() not regenerating .htaccess
- add_rewrite_rule() to route to file other than index.php
- ‘rewrite_rules_array’ or ‘generate_rewrite_rules’ for adding custom rewrite rules?
- Rewrite Rules Are Redirecting and Not Passing VARs
- WordPress rewrite rules don’t need ^?
- custom template rewrite
- Custom rewrite not working
- Disable Pagination on Pages
- How to building pretty URLs to reflect category hierarchy?
- WordPress Rewrites – How can I pass a variable to Custom Post Type?
- Need to add rewrite rule that adds in additional information about the post to url
- How to add a custom redirect rule for Post as subdomains?
- How to preserve the query string while using add_rewrite_rule and default public query vars
- add_rewrite_rule is redirecting instead of rewriting url
- Rewrite rules automatically for pages using specific template
- How to use add_rewrite_rule in subdomain
- Custom Rewrite rule to captured post (rewrite rule to rewrite rule)
- Rewrite the default post object’s permalink
- QSA Rewrite Rule
- Enpoint Not Found in Rewrite Tag Permalink
- How to pass url as a parameter in a add_rewrite_rule
- Per Page Permalink Structure for Page Post Type
- Custom Rewrite Rules
- Customise particular RSS permalink
- URL Rewrite with Custom Variables
- ReWrite rule for files of a previously standalone blog moved to network
- RSS feed rewrite matching wrong rule
- Rewrite /category/cars into /topics/cars
- Best way to trigger rewrite rules
- Trouble with question mark in rewrite rule
- show ALL latest posts with archive.php on example.com/latest
- What URL rewriting rule should I write to retrieve a var in the URL?
- Custom rewrite rule not working
- How to use wp rewrite to hide form action url?
- WordPress Rewrite rule is not working
- How do I make WordPress revise an .htaccess file a certain way?
- How can I allow trailing slashes on some URLs without a redirect, but not on others?
- Can’t use a specific custom URL (slug)?
- How to change an existing wordpress page rewrite rule?
- URL rewriting in wordpress using parameters
- Adding the amp url prefix to the beginning
- Rewrite rules – page does not exist
- Use URI suffix as parameter and ignore when resolving page
- Why wordpress rewrite my custom URL?
- Rewrite rule regex help required
- Redirect empty search to another page
- Rewrite Rules are Redirecting
- Rewrite dynamic URLs as pretty URLs in WordPress functions.php (add_rewrite_rule) – what’s wrong with my code?
- How to redirect to a login virtual page?
- Rewrite rule not working, suspect redirect string
- Issue with custom rewrite for products and permalinks
- Prefix only some posts with a custom prefix
- Help adding custom url, rewrite_rules_array
- How to use a capture from a rewrite rule inside a php file (like single.php)?
- url rewriting on custom post type
- Broken page redirect
- Rewrite rule not redirecting correctly
- Custom taxonomy Rewrite Rule
- add_rewrite Rule
- rewrite rule of post when accessed from archives pages
- I want to add one extra field to my URLs, I’m using Rewrite functions but it doesn’t work
- Rewrite rule is not working
- How to make a custom route with any-string-part/number-part pointing to an existing page?
- rewrite rule for home/index page
- Post Type Rewrite Custom
- Additional .htaccess rules based on wp page
- URL Rewriting in WordPress
- Rewrite URL variable to custom path
- Rename page URL
- Help with url rewrite
- Wrong rewrite rules