404 redirect based on url

I would use the wp hook, which fires right after the request has been parsed and queried: function wpse_199869_wp( $wp ) { if ( ! is_admin() && is_404() && preg_match( ‘/^bh-job/’, $wp->request ) ) { wp_redirect( home_url( user_trailingslashit( ‘jobs’ ) ) ); exit; } } add_action( ‘wp’, ‘wpse_199869_wp’ ); We make sure it’s a 404, … Read more

Many Rewrite Parameters/Rules

The pattern (.+) matches any character, including the slash, so any combo of parameters will always match your first rule, with anything that follows being passed as the version query var. Change all instances of (.+) to ([^/]+) to match all characters except the slash.

Add pagination to a template loaded by query variable

After a bit of digging over the weekend, I found the solution and indeed, it is a rewrite rule with the paged variable added add_rewrite_rule(‘collection/men/page/([^/]+)/?$’,’index.php?post_type=collection&men=yes&paged=$matches[1]’,’top’); Pagination now works in the custom template loaded by query variable. i.e. localhost/sample-site/collection/men/page/2 loads the next page instead of a 404 error

Overwrite WordPress’s URL rewrite not working

WordPress has its own rewriting system in PHP so you can do it both ways If you want to rewrite these url from htaccess, i would only make it rewrite http://www.example.com/newsletter/confirm/token to http://www.example.com/newsletter/?ut=token instead of trying to rewrite http://www.example.com/newsletter/confirm/token to http://www.example.com/index.php?page_id=4058&ut=token And let WordPress handle the page id rewrite. So the htaccess rule would be: … Read more

Rewriting in wordpress url

From this other answer on the WP SE add_action(‘generate_rewrite_rules’, ‘roots_add_rewrites’); function roots_add_rewrites($content) { $theme_name = next(explode(‘/themes/’, get_stylesheet_directory())); global $wp_rewrite; $roots_new_non_wp_rules = array( ‘css/(.*)’ => ‘wp-content/themes/’. $theme_name . ‘/css/$1’, ‘js/(.*)’ => ‘wp-content/themes/’. $theme_name . ‘/js/$1’, ‘img/(.*)’ => ‘wp-content/themes/’. $theme_name . ‘/img/$1’, ); $wp_rewrite->non_wp_rules += $roots_new_non_wp_rules; } TheDeadMedic provided a much better version of this function: function … Read more

Urls in Custom Post Type work for Terms but not for its Taxonomies

[taxonomy_name] should be available in permalink automatically if you register it as register_taxonomy(‘kalendar’, [taxonomy_name], $args ); So Try this foreach($this->months as $month => $month_var) : $args = array( ‘labels’ => array(‘name’ => $month), ‘hierarchical’ => true, ‘rewrite’ => array( ‘slug’ => $month_var ), ‘query_var’ => true ); register_taxonomy($month_var, ‘kalendar’, $args); endforeach; Then Save Permalink Settings … Read more