Question

I'm currently using <?php the_post_thumbnail('250px', array('class'=>"review-siteshot", 'alt' => get_the_title() )); ?>

I know that 'alt' => "review" will output review as all text.

I'm trying to use get_the_title() along with "review" so that I get title-text review as my alt text for the thumbnail.

Était-ce utile?

La solution

Like this:

'alt' => get_the_title(). ' review'

So the full code would be:

<?php the_post_thumbnail('250px', array('class'=>"review-siteshot", 'alt' => get_the_title(). ' review' )); ?>

Autres conseils

The function the_title() can be used to append a string and to return instead of echoing:

the_title( '', ' review', 0 )

In case stripping tags and escaping is necessary, the function the_title_attribute() can be used:

the_title_attribute( [ 'after' => ' review', 'echo' => 0 ] )
Licencié sous: CC-BY-SA avec attribution
Non affilié à wordpress.stackexchange
scroll top