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:
- 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
- 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 (>=)?
- 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?
- Sort wp post title with alphabetically and numerically?
- Exclude posts with specific meta_value while sorting by a separate meta_value
- 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
- WordPress not opening posts with only numbers if permalink is post_name
- Assign category to new post via URL
- filter RSS feed in URL
- Permalink doesn’t get displayed in Twitter button (Local WordPress problem?)
- Start post pagination at 0 instead of 1
- how can i change WP main archives loop to sort by name or title
- how to get post order by post id wp_query?
- How do I Redirect a WordPress Page?
- Linking to pages/posts within the site
- WP move posts to different path
- Sort Custom Post Type by Category ID then Post Name
- Query posts by Author and/or by Tag
- Make insterted image point to post url instead of attachment page
- Post filtering is returning blank page
- Post is blank when I click on the link
- Sort All Posts by Category Name in the Admin Panel?
- Inserting Media to WordPress Posts
- Custom Post Type, post-formats associated to custom post type > 404 archives
- Can Permalink structure of %postname%/%post_id% improve performance
- How to list post as buch of category, and all of them
- 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
- Permalink Short code showing unnecessary link text inside the loop
- Every time I try accessing a post it redirects me to the feed
- 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
- Mix post date with post meta value using WP_Query
- 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
- How to sort posts in admin by name
- Multipage Post URL correction
- Post & Category Archives URL structure
- Post URL duplication adds numerical value
- Embed image in post from external url
- structure of posts and pages
- How to change post template via url?
- 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
- How to get alphabetic listing x other posts, based on first letter post?
- Change the default video URL in a post to shortcode format
- Sort by category and then date?
- custom sort posts in archive/taxanomy page
- 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