How do you stop echo of multiple values with 'foreach' in PHP?

Posted by Aaron EA on Stack Overflow See other posts from Stack Overflow or by Aaron EA
Published on 2012-04-04T18:16:52Z Indexed on 2012/04/04 23:29 UTC
Read the original article Hit count: 220

Filed under:
|
|
|
|

How do you when using custom fields in Wordpress echo just the first value using foreach?

Currently the code is:

    <?php for(get_field('venue_event') as $post_object): ?>
        <a href="<?php echo get_permalink($post_object); ?>"><?php echo get_the_title($post_object) ?></a>
    <?php endforeach; ?>

This takes the field from the wordpress page (the field is a link to another page), creates a link to that page using get_permalink but when I want to echo the page title it does it, but then it also echos all other values that are not needed.

© Stack Overflow or respective owner

Related posts about php

Related posts about Wordpress