Change permalinks structure for specific category

This can be accomplished with some custom filters & actions. Try placing this code in your theme’s functions.php file: add_filter( ‘post_link’, ‘custom_permalink’, 10, 3 ); function custom_permalink( $permalink, $post, $leavename ) { // Get the categories for the post $category = get_the_category($post->ID); if ( !empty($category) && $category[0]->cat_name == “News” ) { $permalink = trailingslashit( home_url(“https://wordpress.stackexchange.com/”. … Read more

URL rewrite based on a custom field value

here is an idea, first add lid to query_vars: add_filter(‘query_vars’, ‘lid_query_vars’); function lid_query_vars($vars) { // add lid to the valid list of variables $new_vars = array(‘lid’); $vars = $new_vars + $vars; return $vars; } then use parse_request hook to create your redirect add_action(‘parse_request’, ‘lid_parse_request’); function lid_parse_request($wp) { // only process requests with “lid” if (array_key_exists(‘lid’, … Read more

Permalinks to Custom does not work (out of box)

Sounds like to that the Allow Override directive is still set to NONE for your VHOST By default this is disabled, so even if you enable mod_rewrite via sudo a2enmod rewrite your .htaccess will be ignored. You’ll want to login to your server (via Terminal / shell) and then … sudo nano /etc/apache2/sites-available/default look through … Read more

How Do I Programmatically Force Custom Permalinks with My Theme?

To fully enable permalinks, you also need to ensure that .htaccess is also created. To do that, you need to set an option and flush the rules with a Boolean. global $wp_rewrite; //Write the rule $wp_rewrite->set_permalink_structure(‘/%postname%/’); //Set the option update_option( “rewrite_rules”, FALSE ); //Flush the rules and tell it to write htaccess $wp_rewrite->flush_rules( true ); … Read more

How to custom change author base without $this->front?

You’re close, but you don’t need the add_rewrite_rule call. add_action(‘init’, ‘wpse82004_init’); function wpse82004_init() { global $wp_rewrite; $wp_rewrite->author_base=”u”; $wp_rewrite->author_structure=”https://wordpress.stackexchange.com/” . $wp_rewrite->author_base . ‘/%author%’; } After that’s in place, just re-save permalinks. Here’s a plugin to put an option on your permalinks page to do this.

Is there a user-facing interface to edit an attachment’s permalink?

This’ll add a slug field to the edit attachment page, which’ll allow you to independently change it when and how you choose to. Drop it into a plugin or your theme’s functions.php; function wpse_12405_edit_attachment_name( $fields, $post ) { $fields[‘post_name’] = array( ‘label’ => __( ‘Slug’ ), ‘value’ => $post->post_name, ); return $fields; } add_filter( ‘attachment_fields_to_edit’, … Read more

Custom Post Type Archives by Date with Custom Permalink

Here’s the solution: Install Custom Post Type Archives plugin Go to Settings->Post Type Archives Remove the url base option (leave it blank) Change the template pattern to archive-{POST_TYPE}.php Tick your custom post type and click save Rewrite/save your custom permalink structure Now your links press-release/%year% and press-release/%year%/%month% should work.