Hi, I am coding a wordpress theme, and I am trying to do something that probably isn't allowed by normal means, so I am wondering if there is a way to go around it. I have a piece of code that calls for the content <?php the_content();?> and then a I have a code that states the directory of the stylesheet <?php bloginfo('stylesheet_directory'); ?> what I am trying to do is this: <?php the_content('<img src="<?php bloginfo('stylesheet_directory'); ?>/images/image.gif" alt="Read More.." />');?> but obviously the <?php bloginfo('stylesheet_directory'); ?> would not come out right in that code, so is there a way to put that <?php bloginfo('stylesheet_directory'); ?> into the <?php the content('here');?> in order to make it work? Regards, Nick
Make bloginfo return the stylesheet_directory, and then just go something like: <? the_content('<img src="' . blog_info('stylesheet_directory') . " . . . ?> and in function blog_info() make sure at the end it has return $stylesheet; or whatever it needs to be returning. I'm assuming this is a string?
I think it's a string. I don't really know php, I just know the php codes that are in wordpress. This is what I have: <?php the_content('<img src="<?php bloginfo('stylesheet_directory');?>/images/read-more.gif" alt="read more..." class="read-more" />'); ?> PHP: basicaly bloginfo('stylesheet_directory');?> calls for the directory of where the stylesheet is located, which is "wp-content/themes/theme-name/". I need to put that in there every time I use the <img src="" /> thing so that an image shows up. (Otherwise it looks in the base directory, and there is no such image there). But the way I have it now, it gives me an error, and I dont have enough php skills to know how it's supposed to be done, so wouldn't you mind showing me? Regards, Nick
<?php $bloginfo = bloginfo('stylesheet_directory'); the_content('<img src="' . $bloginfo . '/images/image.gif" alt="" />'); ?> Code (markup): should work, no?
Nop. That didn't work. It actually shows what the first part is and then doesn't recognize blogifno in the_content. Here is an html output: http://localhost/wordpress/wp-content/themes/themename<p>Hello<br /> Hello<br /> Hello<br /> <a href="http://localhost/wordpress/?p=36#more-36" class="more-link"><img src="/images/read-more.gif" alt="" /></a></p>
Based on what you posted up on the OP, this should work <?php the_content('<img src="' . bloginfo('stylesheet_directory') . '/images/image.gif" alt="Read More.." />'); ?> PHP: If it doesn't work(and it's basically just a rewritten version of what Accelerated Media posted) then there's probably a problem with your bloginfo() function.