What about something like that?
function wpse139657_orderby(){
if( isset($_GET['orderby']) ){
$order = $_GET['order'] or 'DESC';
set_query_var('orderby', 'meta_value_num');
set_query_var('meta_key', $_GET['orderby']);
set_query_var('order', $order);
}
}
add_filter('pre_get_posts','wpse139657_orderby');
In this way you can call your urls with a ?orderby=rank
suffixed and it should do the trick. You can also have an optional order
parameter, should you want to implement it.
Related Posts:
- How to Change Order of Posts in Admin?
- Access post from post id in URL
- How to add category to: ‘wp-admin/post-new.php’?
- How to Check if a Page Exists by URL?
- Random sort within an already sorted query
- Different post sort order within different categories
- Setting Custom Sort Order of Posts within a Category
- Strategy for handling hierarchical pages with empty parent content
- Can I force a metabox to be in one column?
- How to Group Posts by the First Letter or Number?
- How to Arrange Posts by Size in the WordPress Dashboard?
- How to query serialized array by comparing greater than (>=)?
- blog posts sorting doesnt work while using get_query_var
- Open WordPress ‘Add New Post’ admin page with parameters set via $_GET
- How to sort posts by last name (2nd word) on ONE category only?
- Group Posts by First Letter of Title
- How do you get all the urls of images attached to a post?
- How to allow slashes in single posts when i click in the edit permalink button
- Sort wp post title with alphabetically and numerically?
- Exclude posts with specific meta_value while sorting by a separate meta_value
- how to grab first link in post… and of course call it
- How to choose a sort order (for posts) per category? (ideally when creating a new category)
- Working Bootstrap Carousel Conversion to WP – Technical Questions
- Plugin for sortable posts in grid [closed]
- How can I extract the URL of a link from a post?
- Exporting Data from WordPress into a flat table
- How to display sorted posts in the ‘All Posts’ page
- Create a separate JS application for an individual post?
- Sort posts by newest child while keeping hierarchy intact
- Filter Posts by Excluding Categories
- Sorting posts alphabetical that have single digits
- Sorting posts according to the term they belong to
- Sorting posts according to view counts not working
- What Is meta_id In wp_postmeta?
- Server-side sorting of posts
- Remove slashes (both before and after) in relative post url
- Random post category URL
- Paginated Posts – Social Media Buttons Share First Page URL
- How to prevent to create same url of post, if the previous was deleted?
- Get other posts sharing the same meta values
- Can I show category name in url for only one of my categories?
- WordPress posts have a different URL to the index
- Posting to WP via URL
- How to bulk Update URLs to new values?
- Permalink Short code showing unnecessary link text inside the loop
- Every time I try accessing a post it redirects me to the feed
- How can I make a post sub link?
- How to sort WP_Post Object array by object field in php?
- How to mark only one post as Featured post?
- Does having category name in permalinks affect SEO when having a post in multiple categories?
- How to add a ‘News’ section to specific posts in WordPress
- Template for displaying CPT / Taxonomy URL issues
- Get post by two meta key but order by one of them
- Sorting post by custom field and category
- Mix post date with post meta value using WP_Query
- Change WordPress names duplicate titles (url)
- How to generate an HTML link automatically from URL in a users’ post
- Prevent Archive URLs
- Ajaxify Post Sort
- WP_Query to get posts in a specific tag or has post_format
- Category URL to use same string as Post URL Permalink
- How to create frontend Post filter using meta query
- Querying posts from current category, using a variable as array argument
- How to sort posts in admin by name
- If I moved the location of my generic “posts” page, do I need to change the slugs for all of the individual posts?
- Multipage Post URL correction
- Post & Category Archives URL structure
- Post URL duplication adds numerical value
- WordPress URL question
- Embed image in post from external url
- structure of posts and pages
- How to change post template via url?
- How to retrieve a post by inputing the url in a custom field and displaying it on an options page
- Sort / Filter Queries
- Post as frontpage – avoid duplicate content
- Custom URL Structure for posts with subcategories
- How can I display a specific number of post in a category via a url
- Is there a Standard Format for Clean URLs for Archives of Custom Posts?
- Advanced Post Display/Pagination/Ordering
- Create custom URL with different levels
- Sorting Posts by Date – get_blogs_of_user_id()
- Moving Posts to a new site and maintaining URLs
- Make Show Notes for Individual Podcast Episodes Easy to Find (multiple URL’s?)
- Rewrite a specific Post Format to URL slug
- Sort Posts Alphabetically by Multiple Categories [duplicate]
- How to get alphabetic listing x other posts, based on first letter post?
- Change the default video URL in a post to shortcode format
- Choose options via url
- Sort by category and then date?
- custom sort posts in archive/taxanomy page
- Default post type doesn’t display in url
- Do I need to create a multisite for querying posts from multiple WordPress sites?
- Post page still linked to old site
- Blog posts are not appearing as subs of Blog Page
- Filter/Sort Post Form On Taxonomy page
- Sort Posts Alphabetically Based on Specific Category (Divi)
- How to add paraent in Blog post URL in wordpress
- How to sort posts alphabetically based on a specific parent category
- Modify Post URL Programmatically
- How can I change the post order after filtering in WordPress?