0

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?

0

1 Answer 1

2

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.

2
  • 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
    Commented Apr 13, 2011 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
    Commented Apr 13, 2011 at 23:21

Your Answer

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