Custom field value as WP_query tag parameter
-
Hello all
I’m trying to grab posts that have a tag that matches a custom field on the invoked page. (the custom field key is ‘masonry-tag’). on pages without this custom field populated, I am getting all posts, which is good. However, on pages where a the field *is* populated, no results are returned.
i can get the tag value to spit out just fine, so I know I’m capturing the value. Here’s my testing code:
`$filtervalues = get_post_custom_values(‘masonry-tag’);
foreach ( $filtervalues as $value){
echo $value;
};`but when I try to call the query, i get nothing. Code for that here:
`$args = array(
‘post_type’ => array(‘product’, ‘post’),
‘posts_per_page’ => -1,
‘tag__in’ => get_post_custom_values(‘masonry-tag’)
);$query = new WP_Query( $mix_args );
`I’ve been at this particular bug for hours, trying different approaches. PHP really isn’t my strong suit, and I fear I’m going in circles at this point.
Can anybody point me in the right direction here?
Thanks so much in advance for your help
The topic ‘Custom field value as WP_query tag parameter’ is closed to new replies.