I’m still learning PHP and this is for sure just a syntax problem:
I’m trying to output the gallery (basic list of images from here: https://www.advancedcustomfields.com/resources/gallery/) in “plain PHP”.
I’ve already tried almost everything, but nothing seems to work. This is what I have so far at this moment and it causes a white screen:
$members = get_field('team_member');
if( $members ):
foreach( $members as $member ):
echo ='<a href="' . $member['url'] . '">';
echo ='<img src="' . $member['sizes']['large'] . '" alt="' . $member['alt'] . '">';
echo ='<p>' . $member['caption'] . '</p>';
Could anyone help me a bit with this, please?
Since you’re just starting out, the first thing you should do if you’re going to be working on code is to enable debugging. Doing so will let you see the errors that your page is producing rather than a white screen. https://codex.wordpress.org/WP_DEBUG
You’ve got multiple syntax errors, mainly the
= after each
echo. Remove them.
Thanks a lot for the quick reply, John! To put
echo is (of course!) a very stupid failing. I can not believe I did not see that :-/. Very emberassing, it’s time for vacation. Maybe you can delete this useless thread.
WP_DEBUG I will set on true, from now on. That would have helped a lot in this case.
I honestly didn’t see the = thing till I copied your code into my edit and it showed me the errors, it’s amazing the things that can be easily overlooked, especially if you make an error on one line and then copy and paste that line to created another one.