I need to filter my posts in categories pages, by showing only posts that have specific WORD in custom field value. I need php code that i should add in loop for this category.

Details: I need loop query that will say - show posts in this category (crocs) only if custom field hey 'brand' contain the same value (crocs). BUT note, in custom field 'brand' i have more brands, for example 'diesel, crocs, fendi'. Now i need post to show if value contains crocs, not if it's equal to crocs (as other brands can be present).

Thanks a lot for your help. Maybe this is basic, but I am noob and trying to learn and understand WP :)

Cheers, Dean

  • could i do something like - show posts if cat_title exist in meta_value???: <?php query_posts('meta_key=Brand&meta_value=*single_cat_title();*'); ?> <?php get_template_part( 'loop' , 'entry') ?>
    – Dean
    Commented Sep 1, 2012 at 4:34

1 Answer 1

args = array(
    'post_type' => 'product',
    'meta_query' => array(
            'key' => 'brand',
            'value' => 'crocs',
            'compare' => 'LIKE'
$query = new WP_Query( $args );


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.