Tag Info

Hot answers tagged

3

This is a bug 25143 as @toscho pointed out and will be fixed in 4.3 Workaround Found in the ticket and modified a little WordPress adds foo as query var that causes the problem. So, we need to remove it before WP query the DB add_action( 'pre_get_posts', 'wpse191771_unset_query_arg' ); function wpse191771_unset_query_arg($query){ if ( is_admin() || ...


3

Maybe I did not get this very well, but if you need to just remove 'foo' from query vars would not be much more simple to use the 'request' filter and remove the var from there? Code needed: add_filter('request', function($query_vars) { return array_diff_key($query_vars, array('foo'=>'')); }); It: runs on main query only remove the var for $wp ...


3

You can get close to what you want by using the template_redirect hook. function my_custom_search_url_rewrite() { if ( is_search() && ! empty( $_GET['s'] ) ) { wp_redirect( home_url( "/search/" ) . urlencode( get_query_var( 's' ) ) ); exit(); } } add_action( 'template_redirect', 'my_custom_search_url_rewrite' ); Then you can use a URL ...


2

In order to add a parameter to all url of WordPress add_rewrite_endpoint() is more appropriate. I needed to add /foo after all URL so add_rewrite_endpoint("foo", EP_ALL); did the trick.


1

In WordPress you have 3 main kind of "views": singular pages archives search "Standard" home page is just a somewhat special archive page, a static front page a somewhat special singular page. When you use the endpoint page in front page url, WordPress internally sets the query variable page to a specific number (would be paged for regular pages). The ...



Only top voted, non community-wiki answers of a minimum length are eligible