Blank content php code not parsing advanced custom fields gallery add-on [closed]

  1. The very first line contains an incomplete opening PHP tag, it should be <?php not < ?php or some other variation.
  2. Also if statements don’t require a semi-colon after them. Your code is also not indented correctly. A good editor will auto-indent code for you automatically.
  3. A good editor will also syntax check and point out errors as you type them. PHPStorm does this, Sublime Text has a package to enable it
  4. $images = get_field('$jennifergallery'); will not work. It will look for the field with the key ‘$jennifergallery’, not the value of $jennifergallery. If you want to pass a variable into a function, just pass it in, you don’t and shouldn’t need to wrap it in quotes. $images = get_field( $jennifergallery );
  5. get_field is an ACF function, not a WordPress function. If you’re not using ACF, and don’t have it installed and activated, this will fail.
  6. You’re getting a white screen because your PHP is configured to not show errors. Look in your PHP error log file, and it will tell you exactly what went wrong and where. It won’t tell you why it went wrong, but it will tell you what caused it.
  7. You have a lot of unnecessary PHP tags, e.g. ?><?php, this does nothing, takes time to type out, and is pointless. Save yourself the hassle
  8. is_page_template( 'index.php' ) will never return true. You’re not on index.php, you’re on the image scroll template. I strongly recommend looking up the template hierarchy
  9. It may also be that you don’t have any images in the gallery. This is likely because is_page_template('index.php) is always false, so your variable is never set, so you never retrieve the gallery images, so they’re never shown. When this happens, there is no else clause to print “no images were found”
  10. You never give $jennifergallery an initial value. If you’re not on the home people or stories pages, this variable will never have been created, it’s like building a skyscraper penthouse before you’ve laid foundations, it’s going to fall and crash out of the sky.
  11. Would it not just make more sense to have a single field called ‘gallery’ rather than 3? That way you can grab the gallery field on any page and if it has images in it, display them. Now you don’t need a custom page template!