How to redirect a page into file?
Recommend and currently use Quick Page/Post Redirect Plugin https://wordpress.org/plugins/quick-pagepost-redirect-plugin/ Request URL Destination URL /page/ http://example.com/uploades/file.pdf
Recommend and currently use Quick Page/Post Redirect Plugin https://wordpress.org/plugins/quick-pagepost-redirect-plugin/ Request URL Destination URL /page/ http://example.com/uploades/file.pdf
This is straightforward. Hook on init to detect the lostpassword page If the user is not coming from your instructions page (which we defined by adding extra query parameter) he’ll be redirected to your custom page In your custom page add the link to lost password page including the extra parameter we set to skip … Read more
opinion: I like ajax interactions for things like this. DELETEs are cheap, fast things to accomplish server side, loading the whole page all over again takes too long. /opinion If you’re going to use redirects and want to display error messages, you have a couple of options. 1. Use the redirect url itself to pass … Read more
The correct solution is to add the redirect to index.php in your theme – this will ensure only frontend, non-api based requests are handled. Sniffing wp-json in the request is dodgy at best, and will all out break if another plugin overrides the endpoint (which you can do, it’s pluggable). <?php wp_redirect( ‘http://example.com/’, 301 ); … Read more
Number 1 If you want your website to be ONLY accessible through HTTPS, you will want to add this piece of code to your .htaccess file, replacing your domain’s name: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.example.com/$1 [R,L] </IfModule> This will redirect any visits from non-SSL to SSL version of your website. … Read more
You can simply write your own function this way: function get_old_link($url) { global $wpdb; // get only url path $parse = parse_url($url); $path = trim($parse[‘path’], “https://wordpress.stackexchange.com/”); // get last part as slug $arr = explode(“https://wordpress.stackexchange.com/”, $path); $slug = end($arr); // find post id by meta_key and meta_value $row = $wpdb->get_row(“SELECT post_id FROM $wpdb->postmeta WHERE meta_key … Read more
I advice you to try this, better to the action login_init: add_action(‘login_init’, ‘redirect_logged_in_user’); function redirect_logged_in_user() { global $action; /* if the user call logout and is not logged in we do nothing*/ if (‘logout’ === $action || !is_user_logged_in()) { return; } /* we redirect logged in people*/ wp_redirect(‘http://my_homepage_url’); exit; }
You also need to check if the user is on that particular page or not. If he is on that page, then there is no need to redirect him/her again. Change your else to this: if(is_user_logged_in() && function_exists(‘pmpro_hasMembershipLevel’) && pmpro_hasMembershipLevel()) { global $current_user; $current_user->membership_level = pmpro_getMembershipLevelForUser($current_user->ID); echo ‘Membership Level: ‘ . $current_user->membership_level->name; } else { … Read more
Stop URL Guessing – Method 1 The first way to stop WordPress from guessing URLs is to use the below code. To do that, open up your theme’s functions.php file. Once opened, copy and paste the below code and reupload the file. remove_filter(‘template_redirect’, ‘redirect_canonical’); That’s all there is to do. From this point forward, WordPress … Read more
If you want paginated pages to not redirect, you can check the is_paged() boolean. It will return true if you’re on an archive page greater than page 1 ( the first page of the archive ). So if it returns false, it means we’re on the page you want redirected. function my_page_template_redirect(){ $category_array = array( … Read more