What's the correct syntax for quotes within a php statement?
-
Hi there,
Hacking my way through PHP – most of the time okay but cannot work this out so thought I’d ask a far greater power!
I’m trying to echo a field from setup using the advanced custom fields plugin. The query’s working fine on another template but I can’t get the echo to work and I’m sure it’s to do with my ‘newbie’ status.
The code I’m getting blurry eyed over is ,,,
<?php $args = array( 'numberposts' => 3, 'offset' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'publications', 'meta_query' => array( array( 'key' => 'project', 'value' => $post->ID, ) ) ); $posts_array = get_posts( $args ); if( $posts_array ) { foreach( $posts_array as $related ) { echo '<a href="' . $related->guid . '">' . linked words . '</a>'; } }
I want it to echo a field from the related post rather than the guid:
echo '<a href="<?php the_field('field_name'); ?>">' . linked words . '</a>';
But the ” and the ‘ syntax isn’t correct – the ‘ ‘ around the field_name stuffs up the code.
There’s probably an easy, easy answer but stuffed it I can work it out.
Any one got any ideas?
Thanks in advance
- The topic ‘What's the correct syntax for quotes within a php statement?’ is closed to new replies.