Controller functionality – if user is not logged in send them to specific page (not wp_login)

The reason why you are getting a not redirecting properly message is because you are creating an endless loop of redirects. They get redirected to /public but because they are not logged in they get redirected again and again and again… Try this code instead: if( ! is_user_logged_in() && ! is_page(“public”) ) { wp_redirect( site_url(“/public”) … Read more

redirect pages with no content, instead of 404 error, using max_num_posts?

If the rest of your function works you just need to add a call to wp_safe_redirect and hook the whole thing into WordPress. I think that the first hook that will have a populated $wp_query is wp. So alter the last part of your function… if($max_page < $paged){ wp_safe_redirect(get_bloginof(‘url’),’301′); } And then add the following … Read more

Redirect a page based on last word in slug

There are many solutions for that.. 1. .htaccess rules You can put some redirect rules in your .htaccess file: RewriteRule ^(.*)\-staff/$ /staff/? [L,R=301] // some other rules 2. Using WordPress hooks function my_redirect_function() { global $wp; if ( preg_match( ‘@staff/?$@’, $wp->request ) ) { wp_redirect( get_post_type_archive_link( ‘staff’ ) ); die; } // … put other … Read more