user997593 user997593 - 1 year ago 119
PHP Question

the_post_thumbnail_url() causes fatal error with thumbnail support active

I'm working on a child theme from twentythirteen.
Twentythirteen has support fro thumbnails:

add_theme_support( 'post-thumbnails' );

But when I use:


I get a fatal error.
All the google answers say that add_theme_support( 'post-thumbnails' ) has to be in the parent theme functions.php, well, in this case it is there but I'm getting the fatal error anyway.

I have even duplicated the support sentence in the child functions.php (just in case) but still in trouble with this.

The code:

<?php if (have_posts()) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<div class = "ficha curso">
if ( has_post_thumbnail() && ! post_password_required() ) : ?>
<div class="ficha-thumbnail" style = "background: url('<?php the_post_thumbnail_url('large'); ?>') no-repeat; background-size: 300px auto"></div>
<?php endif; ?>

<h3 class="ficha-title"><?php the_title(); ?></h3>

<div class="ficha-resumen">
<?php the_excerpt(); ?>
</div><!-- .entry-content -->
<?php endwhile; endif;

Answer Source

Try this Logic if it does anything for you:

            if ( has_post_thumbnail() && ! post_password_required() ) : 
                $imgURL = wp_get_attachment_url( get_post_thumbnail_id(get_the_ID()) );
                <div class="ficha-thumbnail" style = "background: url('<?php echo $imgURL; ?>') no-repeat; background-size: 300px auto"></div>
                <?php endif; ?>

Hope this does the trick for you... ;-)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download