define orderby URL with meta_key=post_views_count
define orderby URL with meta_key=post_views_count
define orderby URL with meta_key=post_views_count
&orderby=date will return posts by their dates. <?php query_posts(‘post_type=page&post_parent=2&posts_per_page=-1&orderby=date&order=ASC’); ?> Replace first line with this to show post according to their date. Reference – Passing variables to query_posts Update – To sort the posts as per custom field value, Here’s the new code. query_posts(‘post_type=post&posts_per_page=-1&orderby=meta_value&meta_key=next_open_day&order=ASC’); ?> Note – The date should be saved in – YYYY-MM-DD … Read more
Meta query with multiple custom fields for archives page ordering problem
I ran your query and got … ORDER BY wp_postmeta.meta_value+0,RAND() DESC … which is what I expected. If I am reading your question correctly, what you want is … ORDER BY wp_postmeta.meta_value+0 DESC,RAND() … as in this question at SO. That should sort by meta_value first and then randomize any second level ordering that is … Read more
At first glance, I would think your query isn’t correct. Are you echoing out the variables to make sure they are correct? If you are setting ‘post_per_page’ => 4 and you are getting 5 posts, then something seems a bit off. Where it is a number, I believe you can leave off the quotes around … Read more
How to filter a query by multiple meta keys and order by other meta keys
group posts by taxonomy terms
You can use the get_posts() function and create a custom template file for that! This way you can take advantage of all the arguments that function makes use of. For example, to show all posts from a category that has id=47 you would do the following: <ul> <?php global $post; $args = array( ‘numberposts’ => … Read more
Your question is not very detailed. It is hard to work out exactly what you are doing but I am assuming that you are trying to sort posts by a custom meta meta_key/meta_value. This the formula for that (annotated but basically lifted from the Codex): $args = array( ‘post_type’ => ‘your_post_type’, // I don’t know … Read more
query pages by a childs publish date