简体   繁体   中英

How to echo Wordpress default thumbnail via php inside php if else

Hey guys i have this code

<?php  $jthumb = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
 if ($jthumb> "0")
  {
echo $jthumb;
}
  else
 {
 echo "http://placehold.it/350x250&text= Jedcore";
  }
 ?>);background-attachment:fixed;">

What i wanted to do is to replace the http://placehold.it/350x250&text= Jedcore with an image inside my wordpress theme like <?php bloginfo('template_url'); ?>/images/theimage.png <?php bloginfo('template_url'); ?>/images/theimage.png

But i just cant replace it liek that i will prompt an error,

I'm no expert with php :)

try after this change

echo "http://placehold.it/350x250&text= Jedcore";

to

echo get_bloginfo('template_url').'images/theimage.png';

尝试这个:

echo '<img src="'. bloginfo('template_url') . '/images/img.jpg" alt="">';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM