How to code php within php?
-
Hi there. My challenge is this. I’m designing a theme that displays pics beside each post excerpt on the index, tag, category, etc. pages, and am wanting to make the path to the a default image generic so that users of the theme don’t need to mess around in the code – bam, it’s there for you use without worrying about it. The problem for me is that I’m a bit of a hack, and my php skill set isn’t worth much of a hoot. I don’t even find it intuitive. I’ve tried messing around with TEMPLATEPATH, bloginfo(‘stylesheet_directory’); and the like to no avail, so I need a bit of a prod in the right direction. How do I place php within php?
Ok, the working code I have got in the theme is this:
// if there's not a thumbnail else { echo '<img src="http://www.mysite.com/wp-content/themes/supafly/images/default.png" alt="Default Text Goes Here" title="Default Text Goes Here"/>'; } ?></div>Not really useful to anybody else who hasn’t got http://www.mysite.com/ as their domain.
I would really like to have code that reflects:
// if there's not a thumbnail else { echo '<img src="PATH TO STYLESHEET DIRECTORY/images/default.png" alt="Default Text Goes Here" title="Default Text Goes Here"/>'; } ?></div>Can anybody out there help me with meeting this challenge?
Cheers,
J.
The topic ‘How to code php within php?’ is closed to new replies.