-2

Is there something wrong with the line beginning with echo? I'm getting this error but I'm not sure how I can change it: Parse error: syntax error, unexpected '.' on line 74

while ( have_rows('stills') ) : the_row();

    // display a sub field value
    echo '<li><img src="' . the_sub_field('still'); . '" alt="<?php the_sub_field('project_name'); ?>-still"></li>'

endwhile;

I changed it to this but it's still not outputting correctly: echo '<li><img src="' . the_sub_field('still') . '"></li>';

Also, if this isn't the area to ask for help on these types of questions, where can I ask?

Edit: Tried satyr607's solution and this is how it's outputted.

<div class="project-stills">
    <h3>Stills</h3>

    http://localhost/wordpress/wp-content/uploads/2014/12/17.jpg

    <li><img src="" alt="-still"></li>
</div>
J82
  • 8,267
  • 23
  • 58
  • 87

1 Answers1

1

Try this:

echo '<li><img src="' . the_sub_field('still') . '" alt="' . the_sub_field('project_name') . '-still"></li>';

watch your escaping.

satyr607
  • 61
  • 5
  • I get an error saying there's an unexpected `.` on that line. – J82 Dec 08 '14 at 01:29
  • semi colon in between: `('still'); . ` – Kevin Dec 08 '14 at 01:32
  • that line re-introduced the `;` which ends the echo, and `.` is an invalid command. Note that you also should html-escape scrings being sent to a browser, since quotes in the project name for example might break the html. – Andras Dec 08 '14 at 01:34
  • Yeah, that was my bad. Was coding blind (maybe a bit tipsy :P). – satyr607 Dec 08 '14 at 01:40
  • For some odd reason, it's still not outputting correctly. If you check my post above, I updated it with what the code outputs. – J82 Dec 08 '14 at 01:59
  • the_sub_field is using return and not echo ? –  Dec 08 '14 at 02:01
  • in the future if your referring to a ,wordpress or wordpress plug-in, tag it word-press (then i can ignore it) –  Dec 08 '14 at 02:46