Support » Fixing WordPress » Sorting post by meta_key, orderby=meta_value and order=ASC in same category
7 years, 4 months ago
I’am trying to do a filter link for posts in same category, sorting by meta_key, orderby meta_value in order ASC, using in a category-3.php file.
I used the query string in a link ej: <?php bloginfo(‘url’); ?>/category/economic-and-cultural/?meta_key=country&orderby=meta_value&order=ASC but it doesn’t work. If I change de meta_key
If a use the query_post in a themepage it works, but the pagination doesn´t.
Can somebody help me.
Sory for my bad english and thank you..
7 years, 3 months ago
i think the query_post thing can do something with the words “meta_key” and “meta_value”
but for the link you should use variables, like $meta_key
so you should turn your meta keys and values into variables
my english is een worse than yours !
<?php bloginfo('url'); ?>/category/economic-and-cultural/?meta_key=country&orderby=meta_value&order=ASC
Is already a query string, it’s requesting a category…
<?php bloginfo('url'); ?>/category/economic-and-cultural/&meta_key=country&orderby=meta_value&order=ASC
For testing it might be useful to check which query vars were picked up by WordPress..
Place this before your query, just to check which vars are showing as being set/declared/queried..
<pre><?php print_r( array_filter( $wp_query->query_vars ) ); ?></pre>