Moderator
Jan Dembowski
(@jdembowski)
Forum Moderator and Brute Squad
That’s really convoluted (or I haven’t had enough coffee yet).
Putting the PHP inside an echo like that won’t work, plus you want get_bloginfo() instead, and that’s been replaced with a more functional get_stylesheet_directory_uri() as well.
See what I mean about that coffee? 😉
Try this (untested) code instead. Replace
echo "<img src=\"<?php bloginfo('template_directory'); ?>/images/index/1.jpg\" width=\"1081\" height=\"374\" alt=\"mcec\" />";
with
echo "<img src=\"" . get_stylesheet_directory_uri() . "/images/index/1.jpg\" width=\"1081\" height=\"374\" alt=\"mcec\" />";
See if that does it for you.
http://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri
http://codex.wordpress.org/Function_Reference/get_bloginfo
http://php.net/manual/en/language.operators.string.php
change the syntax in this line; for example:
echo "<img src=\"".get_bloginfo('template_directory')."/images/index/1.jpg\" width=\"1081\" height=\"374\" alt=\"mcec\" />";
Thank you for the solution I finally got it working,
. get_stylesheet_directory_uri() . and .get_bloginfo(‘template_directory’).
both works well, but for the sake of clarification, can you explain why
bloginfo(‘template_directory’) does’t work? I thought all 3 of them are the same thing ?
why bloginfo(‘template_directory’) does’t work?
some WordPress functions echo the result, which means it gets directly output ‘to the screen’;
– in WordPress, these functions’ names typically, but not always, start with the_functionname() or simply functionmname()
while other functions return the result, so it is available for string operations, for instance.
– in WordPress, those functions’ names typically, but not always, start with get_functionname() or get_the_functionname()
to find out more in general, search the web for ‘difference between echo and return php’
Thank you for the explanation =)