• I updated my wordpress to version 4.6 and my website completely broke. I would get just a blank white screen if I tried to visit anywhere on my website, including the admin panel.

    After days of debugging I narrowed it down to a function I added into my themes fuction.php file. It’s a code that is supposed to get the caption of the posts featured image and display it where I choose.

    function the_post_thumbnail_caption() {
      global $post;
    
      $thumbnail_id    = get_post_thumbnail_id($post->ID);
      $thumbnail_image = get_posts(array('p' => $thumbnail_id, 'post_type' => 'attachment'));
    
      if ($thumbnail_image && isset($thumbnail_image[0])) {
        echo '<span>'.$thumbnail_image[0]->post_excerpt.'</span>';
      }
    }

    It was working fine before, but now the code above seems to not work. Does anybody know the issue?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter markman641

    (@markman641)

    Well… turns out it’s just the name. I suppose with the latest update they made that a function or something.

    Yeah, the_post_thumbnail_caption() is introduced since 4.6.0
    Most likely blank / white page is happened because of PHP Fatal Error

    It depends on you configuration, usually the first thing to do is to:

    1. if you are on debug mode and debug log is on
    define(‘WP_DEBUG’, true);
    define(‘WP_DEBUG_LOG’, true);
    check your WordPress’ debug.log

    2. if you are not on debug mode then check you server’s error log (need to make sure you turned it on in your server’s configuration)

    The error message is pretty clear:
    [22-Aug-2016 05:12:48 UTC] PHP Fatal error: Cannot redeclare the_post_thumbnail_caption() (previously declared in /somewhere/wp-includes/post-thumbnail-template.php:244) in /somewhere/wp-content/themes/twentysixteen/functions.php on line 453

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘featured image caption breaks website with new update’ is closed to new replies.