macbros
Member
Posted 3 years ago #
I have a date hack that displays an image for the date in my posts. It works perfectly.
What I want to do is use the bloginfo('theme_url') tage in place of the full url to the images.
Here is the working code:
<? php $d = strtolower(get_the_time('D')); echo ("<img src='http://MYURL.com/wp-content/themes/christmas/img/date/{$d}.png'> "); ?>
I want to replace http://MYURL.com/wp-content/themes/christmas
with the
<? php bloginfo('theme_url'); ?> TAG
Is there a way to get the bloginfo inside an existing php tag?
<? php $d = strtolower(get_the_time('D')); echo ("<img src='bloginfo('theme_url');'> "); ?>
Should work. Basically to combine PHP functions together, you strip out <? php and ?> from one of the functions and combine it into the other one where you want it to appear.
macbros
Member
Posted 3 years ago #
Tried that already and it doesn't work.
<?php $d = strtolower(get_the_time('D')); echo ("<img src='bloginfo('theme_url');/img/date/{$d}.png'> "); ?>
would be the full code.
macbros
Member
Posted 3 years ago #
it ends up outputting this.
<img src='bloginfo('theme_url'); /img/date/mon.png'>
macbros
Member
Posted 3 years ago #
OK I got it folks.
I'll past what I got just in case somebody else runs into the problem.
<img src='<?php bloginfo('template_url'); ?><?php $d = strtolower(get_the_time('D')); echo ("/img/date/{$d}.png'> "); ?>
macbros
Member
Posted 3 years ago #
BTW if anybody's interested in making the post dates images all you do is replace this:
<?php the_time('D j M Y'); ?>
with this:
<img src='<?php bloginfo('template_url'); ?><?php $d = strtolower(get_the_time('D')); echo ("/img/date/{$d}.png'> "); ?>
<img src='<?php bloginfo('template_url'); ?><?php $m = strtolower(get_the_time('M')); echo ("/img/date/{$m}.png'> "); ?>
<img src='<?php bloginfo('template_url'); ?><?php $j = strtolower(get_the_time('j')); echo ("/img/date/{$j}.png'> "); ?>
<img src='<?php bloginfo('template_url'); ?><?php $y = strtolower(get_the_time('Y')); echo ("/img/date/{$y}.png'> "); ?>
make you're images and you're good to go.