How to put orderby on a custom field in query_posts
Have a look at the Codex page – you use ‘orderby’ => ‘meta_value’. Specifically, scroll down a bit and read ‘orderby’ with multiple ‘meta_key’s
Have a look at the Codex page – you use ‘orderby’ => ‘meta_value’. Specifically, scroll down a bit and read ‘orderby’ with multiple ‘meta_key’s
WordPress For Loop Prints Unwanted Extra Paragraph Element
Specifying image size used in template the_content
Pagination doesn’t work in query post in tag template
WP_Query is not a general-purpose method for querying the database. It’s specifically designed for querying posts with the intention to loop over them and output templates for them. If you just want arbitrary data from the wp_posts table, then you can just write SQL and use the $wpdb object to run it: $query = $wpdb->prepare( … Read more
How are you associating users to a post? If you meant users as post authors you can try pre_get_posts hook. function user_author_pre_get_posts( $query ) { $user_id = get_current_user_id(); // Get logged in user ID or pass specific user ID here if ( ( $query->is_author() || $query->is_category() ) && $query->is_main_query() ) { $query->set( ‘author__in’, $user_id ); … Read more
My archives page won’t sort posts by month
How can I use query_posts to loop through posts and construct my own content?
I continued to research my issue and ended up finding the solution here: I need query_posts() to order results first by a meta value and then by post ID Basically, it seems the WordPress orderby is screwed. When I examined the SQL it was producing the orderby looked like this: ORDER BY wppc_postmeta.meta_value+0 DESC Which … Read more
Managed to solve my issue. I was missing the meta_key param in the args of my query_posts function. Here it is with the fixed version : $args = array( ‘post_type’ => ‘property’, ‘posts_per_page’ => 20, ‘meta_key’ => ‘my_meta_key’, ‘paged’ => ( get_query_var(‘paged’) ? get_query_var(‘paged’) : 1) );