Articles of wp redirect

How do I redirect /search/ to ?s=

I have a Search page set up which uses the typical GET format <form id=”searchform” action=”http://example.com” method=”get”> <input id=”s” type=”text” name=”s” placeholder=”Search Again”> </form> For users’ convenience, I’d like to have the following url redirect to the search page: http://example.com/search?search-term Redirect to: http://example.com/?s=search-term I also want the rewrite or redirect to handle the case of […]

wp_redirect not working on admin menu page

Im trying to create a admin menu link on the backend dashboard, that will take users to the front end of their site. Im trying to use this code, but for some reason the redirect is not working. // Custom Menus add_action(‘admin_menu’, ‘register_web_menu_page’); function register_web_menu_page() { add_menu_page(‘View My Website’, ‘View My Website’, ‘add_users’, ‘web_menu_page’, ‘web_menu_page’, […]

is_user_logged_in not working to redirect only logged out users

So I have the code below in my functions.php file. It works for logged out users but it also redirects users that are logged in. Can anyone help? add_action( ‘template_redirect’, ‘redirect_to_specific_page’ ); function redirect_to_specific_page() { if ( is_paged() || is_author() || is_single() && ! is_user_logged_in() ) { wp_redirect( ‘http://www.exampleblog.net/members-only/’, 301 ); exit; } } I’m […]

wp_redirect “headers already sent” after front-end submission form

I’m trying to practice with setting up a front-end post submission form. And I’m getting this error: Warning: Cannot modify header information – headers already sent by (output started at /home/sadlight/public_html/members/wp-content/themes/default-child/announcement-submit.php:1) in /home/sadlight/public_html/members/wp-includes/pluggable.php on line 876 announcement-submit.php is my template below. I’ve tried this solution, but no go. Also, when I use wp_redirect in my […]

How to use nonce with front end submission form?

Thanks to a variety of posts on here I’ve managed to put together a front end submission form. After about 24 hours of tweaking I’ve finally got everything working including a redirect to a ‘success’ page after submission, but I have no idea what to do with the nonce. Here is the form page: http://pastebin.com/YWyXL3jY […]

Firing a function AFTER redirect

I am using a function that redirects the user to a custom page, rather than wp-login in the event of errors. In my case I am using the Http Referer function to send the user back to the same page because I have the login form in a modal. How can I execute a function […]

Multisite Redirect issue

I had a working instance of multi-site wordpress running on version 3.4. I have upgraded this to 4.7. Everything seems to be working fine except that when I login to the sub-site it is redirecting me to the main site. This is happening for all the users other than admin.

Password protected page Hash url

I am using owl carosel which takes a hash url to go to a specific slide (http://www.owlcarousel.owlgraphic.com/demos/urlhashnav.html#five) Lets say I want to visit a password protected page with the slider there (site.com/page#slideone) When I visit the page I am asked for a password, upon entering it, the hash at the end is removed after the […]

Can't get rewrite rules working

Basically I want to rewrite: /edit/test-post to an existing page with a parameter: /edit?e=test-post From the examples in the Codex I created: add_filter( ‘rewrite_rules_array’,’my_insert_rewrite_rules’ ); add_filter( ‘query_vars’,’my_insert_query_vars’ ); add_action( ‘wp_loaded’,’my_flush_rules’ ); // flush_rules() if our rules are not yet included function my_flush_rules(){ $rules = get_option( ‘rewrite_rules’ ); if ( ! isset( $rules[‘(edit)/(\d*)$’] ) ) { […]

How to Rename wp-login.php for Multisite?

I want to hide and rename wp-login.php in my URL for branding purposes on a Multisite set up. From this forum post I see that I can change mysite.com/wp-login.php to mysite.com/login by inserting a RewriteRule ^login$ wp-login.php in my .htaccess. I like that the URL bar does not show login redirecting to wp-login. If I […]