Hi,
I would like order the blog post by custom field which contains a number(year) with link.
So If visitor click 123 than the list sort
2012
2013
2014
If click 321 than list sort:
2014
2013
2012.
So I think the best solution use URL but i dont know how.
Yes, you would probably need to use a URL parameter. The first thing you’re going to need to do is add a custom URL parameter, it needs to be something that won’t conflict with WP. Then output these URLs into the page.
Then you need to get this query argument and alter the post query to short by your custom field either ‘ASC’ or ‘DESC’ depending on what link is clicked. http://www.advancedcustomfields.com/resources/query-posts-custom-fields/
Thanks your answer.
But I dont know how to add my custom fields the query and url.
This works in ABC but when need use the custom fileds dont work.
My custom fileds name ‘year’.
mydomain.hu/movies?orderby=year
But its not working.
You would need to output them into the links, for example;
<?php
// whatever function would be used to get the link for the current page
$link = get_the_permalink();
?>
<a href="<?php echo $link; ?>?myvar=ASC">123</a>
<a href="<?php echo $link; ?>?myvar=DESC">321</a>
then you need to alter the query run on the page to add a meta_query. You can find an example of that in the link I gave before and there is more information in the WP documentation http://codex.wordpress.org/Class_Reference/WP_Query