Custom Field?
-
I am trying to add in a custom field onto my function.php page. i have the following:
<?php echo get_post_meta($post->ID, ‘icon’, true) ?>
And it’s pulling the first post’s icon custom field, but for some reason it ONLY pulls that first post’s custom field. Why isn’t it pulling each post’s custom field, like the other parts of the function do? The other parts of the function pull the title and the description of the post (or it seems like it’s an excerpt maybe). Here is the link to the site in question:
http://artifex-design.co.uk/clients/protaxreturns/#
Can anyone tell me how to alter my code to get this to show properly? The above part of the slider pulls the appropriate custom field using the same code.
It’s part of a loop. Maybe this is the problem?
<div id="controllers" class="clearfix"> <ul> <?php for ($i = 0; $i < $featured_num; $i++) { ?> <li<?php if ( $i == 0 ) echo ' class="active"'; ?>> <div class="controller"> <h3><?php echo get_post_meta($post->ID, 'icon', true) ?><?php echo esc_html( $arr[$i]['titletext'] ); ?></h3> <p><?php echo esc_html( $arr[$i]['description'] ); ?></p> </div> </li> <?php } ?> </ul>
Can anyone tell me how to set this up the right way?
- The topic ‘Custom Field?’ is closed to new replies.