Order Posts By Custom Field That is an array of objects
Order Posts By Custom Field That is an array of objects
Order Posts By Custom Field That is an array of objects
Try Below code: $args = array( ‘post_type’ => ‘work’, ‘posts_per_page’ => -1, ‘post_status’ => ‘publish’ ); $the_query = new WP_Query( $args ); $my_categories = array(); if ( $the_query->have_posts() ) { while ( $the_query->have_posts() ) { $the_query->the_post(); $terms = get_the_terms( get_the_ID(), ‘category’ ); if ( $terms && ! is_wp_error( $terms ) ) : foreach ( $terms … Read more
Your query here is fine. It’s the only way to split it up into sections like that, but it belongs on a page template, not the archive. Archives should always use the main loop for its contents. Make the post type private to turn off the archive and just use your queries in a page … Read more
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
Making list of posts with chosen description
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
Try this $args = array( ‘post_type’ => ‘book’, ‘posts_per_page’ => -1, ); $query = new WP_Query($args); while($query->have_posts() ) : $query->the_post(); $date = get_post_meta( get_the_ID(), ‘date_all’, true ); if($date[‘year’] >= 2018 && $date[‘month’] == 3){ the_title(); } endwhile; wp_reset_query();
compare for multiple meta values for same key in wp_query
You forgot the meta_query key in your $args. $meta_query = array( ‘relation’ => ‘OR’, array( ‘key’ => ‘tic_assignment’, ‘value’ => $current_user -> ID, ‘compare’ => ‘=’, ), array( ‘key’ => ‘tic_department’, ‘value’ => $_depts, ‘compare’ => ‘LIKE’, ), ); $_args = array ( ‘post_type’ => ‘tickets’, ‘meta_query’ => $meta_query, ‘posts_per_page’ => 10, ‘orderby’ => ‘date’, … Read more
You should remove your hook before query. function wpse_288691_add_query_after_content( $content ) { $ouptut=””; remove_filter( ‘the_content’, ‘wpse_288691_add_query_after_content’ ); // Do your *** WP_Query *** and assign result to $ouptut. // Reset query by executing `wp_reset_query`. add_filter( ‘the_content’, ‘wpse_288691_add_query_after_content’ ); return $content . $ouptut; } add_filter( ‘the_content’, ‘wpse_288691_add_query_after_content’ ); Do not echo anything inside the filter, only … Read more