Get Custom Field Values by Another Custom Field in WordPress

After struggling with this, I found a workaround that worked. Since every custom field has a connection with my custom post type, I was able to use wp_get_object_terms to get the terms for each custom taxonomy. Using the query to retrieve all posts: $args = array( ‘post_type’ => ‘houses’ ); $houses = new WP_Query($args); $posts … Read more

wp parse_query not working with custom meta value

I ave faced the same issue when I was trying to filter custom-post-type with custom-field but I have resolved this issue in the following steps. Converted custom-field name from writer to _writer and then I have updated following code inside callback function of parse_query hook that I can add custom-field meta_query like $query->set( ‘meta_query’, array( … Read more

Make custom field meta not display if there is not data in it

It could be that there are rows being returned for: have_rows(‘google_drive_links’) but then, nothing returned for the sub fields? $content = get_sub_field(‘google_link_name’); $link = get_sub_field(‘google_link’); Perhaps you could put in an extra check for those two before creating the hr and ul? if (get_sub_field(‘google_link_name’) && get_sub_field(‘google_link’)){ // Create the hr and ul } Depending on … Read more

Display custom post types with custom date field value (before today) & order by custom date field

I prefer to use WP_Query (for more info read “When should you use WP_Query vs query_posts() vs get_posts()?“), try this way: $args = array( ‘post_type’ => ‘soiree’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘orderby’ => ‘date_de_concert’, // you don’t need ‘meta_key’ => ‘date_de_concert’ when using meta_query //’meta_key’ => ‘date_de_concert’, ‘order’ => ‘DESC’, ‘meta_query’ => array( … Read more