WP template tags in PHP?
-
I have the following piece of code which I will need to repeat many times in my template. Ideally I would like to store it as a snippet so I can call it up when I need it, and also so I can be sure all of the times it is used it will be the same. What would be the best way to do this?
<a href="<?php the_permalink(); ?>"><img src="/wp/wp-content/themes/default/images/<?php echo $post->post_name; ?>.jpg" width="60" height="80" alt="<?php the_title(); ?>" /></a>
Obviously I can store non-WP code by doing something like this:
$snippet = “Text”;
But what about when the code includes WP template tags? How do I put them into PHP? What is the correct syntax? (BTW it will be appearing at random points in the page and will be linked to separate queries; it’s not a string of posts one after the other.)
Hope someone can help! ??
- The topic ‘WP template tags in PHP?’ is closed to new replies.