how to query posts using value in meta post array
how to query posts using value in meta post array
how to query posts using value in meta post array
Ok, Ive found that ‘compare’ => ‘!=’ slows it down, but ‘compare’ => ‘<>’ does not. I guess both are the same, so I guess this question is solved.
you can create conditionnal arguments like that : $user_args = [ ‘orderby’ => ‘display_name’, ‘order’ => ‘asc’, ‘meta_query’ => array( array( ‘key’ => ‘verifier_assign_country’, ‘value’ => $countryCode, ‘compare’ => ‘=’ ), ) ]; if (“” !== $univCode) { $user_args[“meta_query”][] = array( ‘key’ => ‘verifier_assign_univ’, ‘value’ => $univCode, ‘compare’ => ‘LIKE’ ); } $users = get_users($user_args);
OK, so a little bit of guessing is involved in that answer, since you’ve posted only parts of your code, but… I assume that your code looks like that: $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘post_category’ => array(14,16,19) ); $posts = get_posts($args); foreach ( $posts as $post ) { … Read more
It’s a little bit off-topic, but nevertheless… Let’s say you want to change first range_cost to 5.789 and third to 6.890 for product 148. Here’s the code: $product_attr = get_post_meta( 148 , ‘redq_day_ranges_cost’); $product_attr[0][0][‘range_cost’] = 5.789; $product_attr[0][2][‘range_cost’] = 6.890; update_post_meta(148, ‘redq_day_ranges_cost’, $product_attr);
Move Entry Meta Above Title in Archives (Genesis + Brunch Pro)
I cannot test this because I don’t have your code, but maybe you can get some ideas from it: add_filter( ‘wp_unique_filename’, ‘custom_image_name’, 10, 2 ); $img_id01 = media_handle_upload( ‘img_main’, $postID ); remove_filter( ‘wp_unique_filename’, ‘custom_image_name’, 10, 2 ); function custom_image_name( $filename, $ext ) { global $postID; $post = get_post( $postID ); return $filename . ‘-‘ . … Read more
The reason for that is the save_post loop. When you call wp_insert_post, it triggers save_post and thus inserts the student meta. what you can do is, to check if the post type is correct while inserting the meta. like: add_action( ‘save_post’, ‘save_student_meta’, 10, 2 ); function save_student_meta( $post_id, $post ) { if ( ‘student’ !== … Read more
It depends how and where you use this string. Possibly, you have to localize the date according to the site settings: <?php $date_format = get_option( ‘date_format’ ); $timestamp = strtotime( get_the_time() ); $localized_date = date_i18n( $date_format, $timestamp );
Get post content before rendering