How do I redirect a post url to a custom url?

Well, actually WordPress provides wp redirect function. And here is a small plugin I’ve used a while back <?php $redirect_meta_key = ‘redirect_to’; add_action(‘template_redirect’, ‘redirect_this’); function redirect_this($nothing) { global $wp_query, $redirect_meta_key; if(is_single() || is_page()) { $redirect = get_post_meta($wp_query->post->ID, $redirect_meta_key, true); if(” != $redirect) { wp_redirect($redirect); header(“Status: 302”); exit; } } } ?> No all you have … Read more

Custom rewrite rule ignored

The rewrite rules are correct, but because you are modifying the $wp_rewrite directly, you aren’t getting the benefit of being able to add the rule to the top of the stack using add_rewrite_rules. You are on the right track with the location of the rule in the array, but rules at the top are checked … Read more

Fixing custom rewrite rule

I see a second ? in your query variables (before the cls query variable), probably from experimenting with the commented-out form, I think you want to use & there. Your query_vars hook currently adds the id variable, but you use cls and ch in your rewrite rule, so this will not have an effect. If … Read more

How to rename ‘Tag Base’ with WPeC 3.8?

Tags are a custom taxonomy called product_tag in WPEC 3.8+, they’re not the same taxonomy as default WordPress tags so that’s why tagbase has no effect. Line 315 in wpsc-core/wpsc-functions.php: register_taxonomy( ‘product_tag’, ‘wpsc-product’, array( ‘hierarchical’ => false, ‘labels’ => $labels, ‘rewrite’ => array( ‘slug’ => “https://wordpress.stackexchange.com/” . sanitize_title_with_dashes( _x( ‘tagged’, ‘slug, part of url’, ‘wpsc’ … Read more

How to redirect a link to a new link?

Go with the easiest alternative of all: do nothing. No, really: WordPress itself handles redirects for renamed Post Titles. Edit Apparently, the retention of _wp_old_slug only happens for non-hierarchical objects. So, since Pages are hierarchical, they don’t get to enjoy the auto-magic slug redirection. Therefore, for static Pages or other hierarchical post objects, I would … Read more