Pretty basic problem, so sorry but have been banging my head off the wall for well over an hour.
basically writing a script to set a default Wordpress featured image for a category if there is no featured set.
if ( get_the_post_thumbnail( $projects->post->ID ) ) {
$imagetag = get_the_post_thumbnail( $projects->post->ID, 'portfolio-thumb', array( 'class' => 'img-square', 'alt' => get_the_title($projects->post->ID) ) ).''; }
else {
$imagetag .='<img src="ThisIsMySite\img\"'.$tag->slug .'"image.jpg" />';
}
All works, except I can't get the else image to work, the closest I can get is to output :
img src="ThisIsMySite\img\"maths"image.jpg"
(Where maths is the current category) It must be something stupid / really obvious I'm missing / doing wrong but I can't work it out.
"use this'<img src="ThisIsMySite\img\'.$tag->slug .'image.jpg" />'- cmorrissey.=, shouldn't it just be=without the period? - AndyWarren$imagetagvariable outside the conditional, but if that is the case then the if value would also need to be concatenatred. Right? - AndyWarren$imagetagdoesn't exist then the.=will create it by concatenating the string onto anullvalue. - Martin