Separate by Category Post Type

To get custom post type posts with specific category use custom taxonomy Register the taxonomy name of the custom post type like location and then assign location to each post when you added new post. Here is the example of the code add_action( ‘init’, ‘hotels_my_taxonomy’); function hotels_my_taxonomy(){ // custom post type taxonomies $labels = array( … Read more

query all posts published by certain user id

You are querying for post author with ID 8 and also you are telling to match the post type to property post type and also post_status to be either publish, acf-disabled, private. Check your post that didn’t be return for the above and will found the reason. SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND … Read more

Query string order by custom field

The query_posts is only useful when you actually know what you are doing. Base on the info you provide this should work for you : $the_query = new WP_Query(array( ‘post_type’ => ‘your_cpt’, ‘posts_per_page’ => -1,//get them all ‘meta_key’ => ‘field_4’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘DESC’ )); ?> <?php if( $the_query->have_posts() ): ?> <ul> <?php … Read more

Get all wp_users sort by metakey

You can index each of the arrays and then orderby 1 or both of them using ASC,DESC as per your requirement $meta_query_args = array( ‘relation’ => ‘OR’, // Optional, defaults to “AND” ‘no_login’ =>array( ‘key’ => ‘user_last_login’, ‘compare’ => ‘Not Exists’ ), ‘login’ => array( ‘key’ => ‘user_last_login’, ‘compare’ => ‘Exists’ ) ); $meta_query = … Read more

taxquery taxonomy get terms

so if $trips_list is the sample trips section, and you want the sample trips to only show trips with the same terms – you’d find the current trips term and argue that in your WP_Query. // this trips terms $tripTerms = wp_get_post_terms( get_the_ID(), ‘reisezweck’); // if each trip only has one term (as its a … Read more