0

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 Sep 1 '12 at 4:34
0
args = array(
    'post_type' => 'product',
    'meta_query' => array(
        array(
            'key' => 'brand',
            'value' => 'crocs',
            'compare' => 'LIKE'
        )
    )
 );
$query = new WP_Query( $args );

http://codex.wordpress.org/Class_Reference/WP_Query

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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