Please I really need your Help
Moderator
Jan Dembowski
(@jdembowski)
Forum Moderator and Brute Squad
Try get_bloginfo('stylesheet_directory');
instead and see if that works better for you.
The problem is bloginfo is echoing the output
Use this function instead http://codex.wordpress.org/Template_Tags/get_bloginfo
<?php
$thumb = get_post_meta($post->ID,'Thumbnail', true);
$thumb = ( !empty( $thumb ) ) ? $thumb : '<?php get_bloginfo('stylesheet_directory');?>/images/whitebg.jpg';
print '<img src="' . $thumb . '" width="80" height="80" alt="" />';
?>
jdembowski thanks for your Answer but I have tried, does not work
If I view the image, I get the web address URL like this: http://localhost/wordpress/%3C?php%20get_bloginfo(%27stylesheet_directory%27);%20?%3E/images/whitebg.jpg
😉
Like stvwlf said, use get_bloginfo() INSTEAD of bloginfo()…
get_bloginfo DOES NOT echo, unlike bloginfo….
Ok Thank you everyone, but I have solved my own problem 😉
here is the Problem
<?php
$thumb = get_post_meta($post->ID,'Thumbnail', true);
$thumb = ( !empty( $thumb ) ) ? $thumb : '<?php get_bloginfo('stylesheet_directory');?>/images/whitebg.jpg';
print '<img src="' . $thumb . '" width="80" height="80" alt="" />';
?>
here is the Problem solved.
<?php
$thumb = get_post_meta($post->ID,'Thumbnail', true);
$thumb = ( !empty( $thumb ) ) ? $thumb : './wp-content/themes/mytheme/images/whitebg.jpg';
print '<img src="' . $thumb . '" width="80" height="80" alt="" />';
?>
Thank you everyone and Good night
Hi, the problem was this line..
$thumb = ( !empty( $thumb ) ) ? $thumb : '<?php get_bloginfo('stylesheet_directory');?>/images/whitebg.jpg';
Which should be..
$thumb = ( !empty( $thumb ) ) ? $thumb : get_bloginfo('stylesheet_directory').'/images/whitebg.jpg';
Due to the second <?php
….
Incorrectly switching in/out of PHP…
I skimmed over the post before because the solution was already given.
Thanks t31os
I have change instead of this get_bloginfo('stylesheet_directory')
to
get_bloginfo('template_directory')
like this:
<?php
$thumb = get_post_meta($post->ID,'Thumbnail', true);
$thumb = ( !empty( $thumb ) ) ? $thumb : get_bloginfo('template_directory').'./images/whitebg.jpg';
print '<img src="' . $thumb . '" width="80" height="80" alt="Post Thumb" />';
?>
and It works great! 😉
Thanks for the get_bloginfo tip!