A change in URL slug in database returns 404, how can I do auto-redirect?

If you look in the database in the $wpdb->postmeta table you will see a meta_key named _wp_old_slug. That is how WordPress tracks slug changes. By editing the database directly you bypassed the mechanisms that create that postmeta entry. You never want to edit the database directly if you can use WordPress Core functions instead. Attempting … Read more

Why is a rewrite rule in wordpress prevent pagination?

I changed: add_rewrite_rule(‘^brand-list/([^/]*)/([^/]*)/page/([0-9]+)?’,’index.php?pagename=brand-list&brand=$matches[1]&section=$matches[2]&paged=$matches[3]’,’top’); to: add_rewrite_rule(‘^brand-list/([^/]*)/([^/]*)/page/?([0-9]{1,})/?$’,’index.php?pagename=brand-list&brand=$matches[1]&section=$matches[2]&paged=$matches[3]’,’top’); Note the difference is /page/([0-9]+)? is now /page/?([0-9]{1,})/?$ seems to be working now.

Dynamically generated URL and Content page

Firstly, don’t forget to always flush your rewrite rules by going to Settings -> Permalinks and just clicking on Save Changes Now on your problem, it seems that you’re missing an ‘&‘ in your query: $new_rules[‘^test-directory/(.*)/(.*)’] = ‘index.php?test-directory=$matches[1]&test-code=$matches[2]’; Notice the & after $matches[1] On the other hand, your ‘template_redirect’ action is not calling the correct … Read more

Why does my URL keep returning 404 error code?

Here is the solution of my problem, thanks to @Milo: function wpa_date_archive_post_types( $query ){ if( $query->is_main_query() && $query->is_date() ): $query->set( ‘post_type’ , array( ‘movie’ ) ); $query->set( ‘year’ , 0 ); $query->set( ‘tag’ , ‘1994’ ); $query->set( ‘post_status’ , array( ‘publish’ ) ); endif; } add_action( ‘pre_get_posts’, ‘wpa_date_archive_post_types’ );

Mobile version and URL Rewrite

You can change the options siteurl and home. add_action(‘after_setup_theme’, ‘maybe_mobile_url’); function maybe_mobile_url() { if ( wp_is_mobile() ) { add_filter(‘option_siteurl’, ‘add_mobile_url’ ); add_filter(‘option_home’, ‘add_mobile_url’ ); } } function add_mobile_url ($url) { return $url . ‘/mobile’; } But, I think, that if you define WP_SITEURL and/or WP_HOME in config.php it will fail, and you will have to … Read more

Thousands of 404 errors on old posts due to embedded links

I am about 99% sure the reason for much of this is that someone has used relative links in the post body. A link that looks like this: <a href=”www.whufc.com/”>Some link Test</a> Will end up looking like this: 2010/premiership-forecast-title-race-hots-up-gunners-prepare-for-adebayor/www.whufc.com/ If it shows up on this page of the site: 2010/premiership-forecast-title-race-hots-up-gunners-prepare-for-adebayor/ You need to have the … Read more

Permalink issues with custom taxonomies

I think that when you define custom rewrite slugs in the registration of a custom taxonomy, you still need to add custom rewrite rules. add_action(‘init’,’my_add_rewrite_rules’); function my_add_rewrite_rules() { add_rewrite_rule( ‘rights/category/(.+)/page/([0-9]{1,})/?$’, ‘index.php?post_type=rights&category=$matches[1]&paged=$matches[2]’, ‘top’ ); add_rewrite_rule( ‘rights/category/(.+)/?$’ , ‘index.php?post_type=rights&category=$matches[1]’ , ‘top’ ); } In order to add the correct rewrite rule I would need the code of … Read more