WP_Query, Custom Taxonomy, Custom Field Comparison
-
I have run into a tricky issue.
On a page I am building I am using WordPress WP_Query to compare a custom post type’s ACF field with a custom taxonomy term. This are my WP_Query args:
$args = array( 'post_type' => 'photographs', 'tax_query' => array( array( 'taxonomy' => 'subjects', 'field' => 'name', 'terms' => get_field( 'subject_first_name', get_the_ID() ) . ' ' . get_field( 'subject_last_name', get_the_ID() ), ), ), 'meta_query' => array( 'photo_date' => array( 'key' => 'photo_date', 'type' => 'NUMERIC', 'compare' => 'EXISTS', ), ), 'orderby' => array( 'photo_date' => 'ASC', ), 'posts_per_page' => -1, );
The code works fine until the text I am comparing includes an apostrophe. For example, when the text is Georgia O’Keeffe.
ACF get_field returns the text with the apostrophe converted to an HTML Character Entity
' ;
. The custom taxonomy appears to return the text with an actual apostrophe. I do not find a match (even though there are three).I have tried using the following on the ACF get_field return:
esc_sql
$wpdb->prepare
html_entity_decodebefore comparing it with the custom taxonomy, nothing seems to help.
I am a little lost. Any pointers, thoughts, help … magic silver bullets … greatfully appreciated.
Regards
Mike
- The topic ‘WP_Query, Custom Taxonomy, Custom Field Comparison’ is closed to new replies.