Tag Info

New answers tagged

0

pagename is for the page post type, if you are trying to pass the slug for the presskit post type, remove post_type and pagename and just set presskit=$matches[1] instead.


0

The default "pretty" alternative to ?s= is /search/ - you should be able to use that right now. If you want to change it to student, add this to your functions.php file: function re_rewrite_rules() { global $wp_rewrite; $wp_rewrite->search_base = 'student'; } add_action('init', 're_rewrite_rules');


0

I have cracked it. :) Here is my solution. add_rewrite_rule('^(property-details)/([^/]*)/?', 'index.php?pagename=$matches[1]&propertyidtag=$matches[2]','top'); add_filter('query_vars', 'foo_my_query_vars'); function foo_my_query_vars($vars){ $vars[] = 'propertyidtag'; return $vars; } Thank you for your help


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 ...


0

First of all, you have to make sure to register your public query vars with WordPress so it recognizes your rewrite rule vars. Add this code on your functions.php file: add_rewrite_rule('^(tips)/([^/]*)/([^/]*)/?', 'index.php?name=$matches[1]&id=$matches[2]&filter_id=$matches[3]','top'); add_filter('query_vars', 'foo_my_query_vars'); function ...


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 ...


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 ...


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() || ...


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.


0

You could use 2 of Wordpress' built in functions to get the result you're after. add_rewrite_tag() and add_rewrite_rule() There is an example of how to use these tags to get the result you want about halfway down this page https://codex.wordpress.org/Rewrite_API/add_rewrite_rule. Note: remember to flush your rewrite rules.


0

after adding a new rule, you have to flush the rewrite-rules in order to use them that can be done with the "flush_rewrite_rules" function http://codex.wordpress.org/Function_Reference/flush_rewrite_rules or it can be done in going in the Administration Screens -> Settings -> Permalink and just saving without changing something on this screen


0

Have a look at the Action Reference to see generally how requests are processed. After all the loading and init stuff happens, the parse_request action runs when the request is matched against the rewrite rules, and an object is passed containing all the registered query vars and the matched rule and query string. function wpd_parse_request( $request ){ ...


0

Use the function get_query_var: WordPress Codex Function Reference for get query var $someVariable = get_query_var('paramter1');


0

cat is a reserved query variable used for the ID of a post category. To avoid conflicts with WordPress and/or other plugins and themes I'd recommend you 'namespace' your query variables eg eddh_cat instead of cat



Top 50 recent answers are included