Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This snippet pulls in post "industry" for the current post

$post_meta = get_post_meta( $post->ID ); 

This code pulls in all the logos for the "brands"

<?php query_posts( 'post_type=brands&orderby=title&order=ASC&posts_per_page=-1' );          
            $i = 0;
            if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
                <li id="feature<?php echo $i; ?>"><a href="<?php the_permalink(); ?>" rel="<?php echo $i; ?>"><image src="<?php echo get_post_meta( $post->ID, 'brand_logo_sm', true ); ?>" /></a></li>
            <?php $i++; endwhile; wp_reset_query(); ?>

I need some help limiting the the above code to ONLY display the brands that match the "$post_meta"

If have tried:

<?php query_posts( 'post_meta=brand_industry&orderby=title&order=ASC&posts_per_page=-1' );

With not lock.

Any tips?

Thx!

Function where I declare the meta:

$brand_meta = array(
    'brand_email' => 'Email',
    'brand_url' => 'Website',
    'brand_stores' => 'Global Store Locator ID',
    'brand_gallery' => 'Gallery ID',
    'brand_products' => 'Products',
    'brand_industry' => 'Industry'
);

Answer to comment below:

This code, outputs all the logos.

<?php query_posts( 'post_type=brands&orderby=title&order=ASC&posts_per_page=-1' );          
            $i = 0;
            if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
                <li id="feature<?php echo $i; ?>"><a href="<?php the_permalink(); ?>" rel="<?php echo $i; ?>"><image src="<?php echo get_post_meta( $post->ID, 'brand_logo_sm', true ); ?>" /></a></li>
            <?php $i++; endwhile; wp_reset_query(); ?>

I only want it to display the logos if the "industry" gets outputted using this code:

<?php $post_meta = get_post_meta( $post->ID ); ?>

is equal to X

Thant make sense?

share|improve this question
add comment

1 Answer 1

This makes no sense, required $key argument (defines which custom field value you want to retrieve) is missing:

$post_meta = get_post_meta( $post->ID );

How are you actually assigning this to post? In this snippet you only assign array to some arbitrary variable:

$brand_meta = array(...

Also please clarify your condition, I am not sure what you mean by brands that match $post_meta.

share|improve this answer
    
Hi, This code, outputs all the logos. <?php query_posts( 'post_type=brands&orderby=title&order=ASC&posts_per_page=-1' ); $i = 0; if ( have_posts() ) while ( have_posts() ) : the_post(); ?> <li id="feature<?php echo $i; ?>"><a href="<?php the_permalink(); ?>" rel="<?php echo $i; ?>"><img src="<?php echo get_post_meta( $post->ID, 'brand_logo_sm', true ); ?>" /></a></li> <?php $i++; endwhile; wp_reset_query(); ?> I only want it to display the logos if the "industry" gets outputted using this code: <? $post_meta = get_post_meta( $post->ID ); ?> is equal to X Thant make sense? –  user4649 Apr 13 '11 at 23:21
1  
@ryan this seems to be copy of snippet you had already posted in question, it doesn't help much. You need to explain what condition exactly you want to implement and how related data is stored in meta. –  Rarst Apr 13 '11 at 23:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.