Need help with custom fields
-
Hi,
I am trying to retrieve the value of one of my custom fields. The problem is my code only returns the post id, not the value. I’m perplexed because my code works for the other fields.
I have a custom field, manufacturer_image defined as an image and I’m looking for the image URL.
Any advice would be appreciated!
Here is my code:
if ( have_posts() ) : while ( have_posts() ) : the_post(); $div_start = '<div class="data-row">'; $name = get_the_title(); $link = get_permalink(); $url = get_post_meta( get_the_ID(), 'manufacturer_url', true ); $logo = get_post_meta( get_the_ID(), 'manufacturer_image', true ); $div_end = '</div>'; $loop = ''; // init if ( $div_start ) { $loop .= sprintf( '%s', $div_start ); } if ( $logo ) { $loop .= sprintf( '<div class="data-column-one"><img src="'.$logo.'" alt="" class="manufacturer-image"></div>', $logo ); } if ( $name ) { $loop .= sprintf( '<div class="data-column-two"><a href="'.$link.'">%s</a></div>', $name ); } if ( $url ) { $loop .= sprintf( '<div class="data-column-three"><a href="'.$url.'">%s</a></div>', $url ); } if ( $div_end ) { $loop .= sprintf( '%s', $div_end ); } printf( '<div class="%s"><div class="widget-wrap"><div class="post-wrap">%s</div></div></div>', join( ' ', get_post_class() ), $loop ); endwhile;
The page I need help with: [log in to see the link]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Need help with custom fields’ is closed to new replies.