How can I Rewrite a ‘page’ URL based on query string parameters?

You can add a rewrite rule such as the following. Make sure to register your public query vars with WordPress so it recognizes your rewrite rule vars. 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 foo_my_query_vars($vars){ $vars[] = ‘id’; $vars[] = ‘filter_id’; return $vars; } Visit the Permalinks Settings page to flush your permalinks. You can access your … Read more

How to remove query string from static resources

It looks like you are using JetPack’s Photon which adds query strings to your URLs. According to this thread there is no way to remove them https://wordpress.org/support/topic/how-to-remove-photon-query-string?replies=2 If you want to get rid of the query strings I would suggest deactivating photon, using a CDN which does not add query strings, and using the snippet … Read more

How to get a URL parameter from a URL with get_query_var?

I managed to find a solution with some help from some developers at the theme.co apex forum. I needed to get two query strings from my URL www.randompage.com/tokensuccess/?token=token&username=username called token and username. In order to get this I added the following code to the functions.php code: function add_query_vars_filter( $vars ){ $vars[] = “token”; $vars[] = … Read more

Is it possible to add an admin page using add_submenu_page() and pass a var in the query string?

Your menu slug (5th parameter) can’t be the same across multiple pages, and it obviously can’t have an & in it, but you can have all the pages you want call the same callback function (the last param). add_submenu_page(‘upload_manage’, “Programs”, “Programs”, ‘manage_options’, ‘manage-programs’, “manage_data”); add_submenu_page(‘upload_manage’, “Schedule”, “Schedule”, ‘manage_options’, ‘manage-schedule’, “manage_data”); Then in the manage_data function, … Read more

order by second word in title?

There is a filter, ‘posts_orderby’, which allows you to specify your own ORDER BY clauses. In your case, the code would look something like this: add_filter( ‘posts_orderby’, ‘order_by_surname’ ); function order_by_surname( $orderby, $query ) { // first you should check to make sure sure you’re only filtering the particular query // you want to hack. … Read more