WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm developing a theme which supports WordPress' post formats. As a result I am using a big if statement, which can be found below.

  • I would like to link my post titles to the posts while maintaining my theme as XHTML valid.
  • I would like to call images (with classes) in the if statement while maintaining my theme as XHTML valid.
  • I would appreciate if somebody could add the appropriate code to the following code to do so


if ( has_post_format( 'video' )) {
                echo the_title();
                echo the_excerpt();

EDIT: Basically, the most important thing I'm looking for is that it calls the post name as a link which links to the actual post.

share|improve this question
up vote 1 down vote accepted

I don't know what you mean by "call images", but this will display the title as a link.

if ( has_post_format( 'video' )) {
   ?><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><?php 
share|improve this answer
This doesn't link to the post, just to the homepage. Also, it outputs the permalink onto the page when I'm just trying to get it to link to the_title() – Lucas Jun 28 '11 at 17:18
Corrected the code. The echo was slightly broken. Also, your code didn't need echos in the first place, which I missed. – Otto Jun 28 '11 at 19:17

You only need to add in the <a href="<?php the_permalink();?>"><?php the_title();?></a> to link the post and also add the title as the visible part of the link. Also you can replace <?php the_title();?> for a thumbnail (with the correct funct.) or an image, a video, a button, etc. and another kind of php stament as well <?php your_function(your args);?>.

As far as your other question goes, I think that you'll need to add a category for videos and make an special CSS for that. I'll leave two posts, they are in spanish but they are really useful and they work very well: first how to add a different structure How to: different structure per category and then how to style it How to: style each category differently

Hope you find this response helpful ^^

share|improve this answer
That's getting me closer, but still not quite there. Basically, I want to link echo the_title(); to the post. – Lucas Jun 28 '11 at 19:11


<?php if ( has_post_format( 'video' )) { ?>
    <a href="<?php the_permalink();?>"><?php the_title();?></a>
    <?php the_excerpt();?>
<?php } else {;?> If you plan on adding something else. otherwise just delete this line and close with the next one only

<?php } ;?>

And that's it, hope you find this helpful!!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.