Redirect old URL (with different post ID) to new URL

Note: The suggested method will be updated from time to time after collecting more information from the asker. The current suggested method assumed some conditions. The following code is for putting in functions.php, if you are writing a plugin. Please remember to change the callback and write in plugin mode. For more about plugin writing, … Read more

How do I write a subdomain redirect?

Found answer here, first result by searching redirect to different domain apache htaccess <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} ^example.au$ [OR] RewriteCond %{HTTP_HOST} ^www.example.au$ RewriteRule (.*)$ http://www.example.com/$1 [R=301,L] </IfModule> It doesn’t matter if just your TLD is different the same format will work

301 redirect any RSS feed on level up url

So to redirect /en/shipper/feed/ to /en/shipper you should be able to add this in your root .htaccess. You’ll have to make sure you put it in the right place so that it gets matched before any other Rewrite rules – putting it at the top of the list of RewriteRule’s should be fine. These rules … Read more

Conditional redirect to several pages

So you need this to happen before WordPress has output anything at all, otherwise you won’t be able to send a redirect. A way to achieve this is with the template_redirect hook, documented here: https://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect The example from that docs page is more or less exactly what you want. I’ve edited it a little bit … Read more

How can I redirect users on the new 404 page without plugin?

You can assign the 404.php as a template to your custom 404 page created with the page builder. You would need to edit the 404.php to something like this: <?php /** * Template Name: 404 */ get_header(); $query = new WP_Query([ ‘posts_per_page’ => 1, ‘post_type’ => ‘page’, ‘meta_key’ => ‘_wp_page_template’, ‘meta_value’ => basename(__FILE__) ]); if … Read more

Redirect away from page if user is not admin

The basic principles of this are easy enough, but how to implement it in your case is hard to say without knowing more. if ( !is_user_logged_in() ) { auth_redirect(); } Would redirect a non-logged in user to the login page if (current_user_can(‘administrator’)) Would be used to identify whether someone had the admin role. How to … Read more