WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Post Format, and Code (3 posts)

  1. 3Plumes
    Member
    Posted 2 years ago #

    I'm having a bit of a problem adding the if, else statement to my loop so that I can display differently based on the post format. Can anyone see the error in my code?

    <?php if (have_posts()) : ?>
                <?php while (have_posts()) : the_post(); ?>
                    if ( has_post_format( 'status' )) {
                        <h3><a href="<?php echo get_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
                        <span class="postmeta">Published on <?php the_time('F jS, Y') ?> in <?php the_category(', ') ?></span>
    	                <?php the_content(); ?>
    	            }
                    else {
                        <h3><a href="<?php echo get_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
                        <span class="postmeta">Published on <?php the_time('F jS, Y') ?> in <?php the_category(', ') ?></span>
                        <?php the_excerpt(); ?>
                        <p><a href="<?php echo get_permalink(); ?>" title="Continue reading">Continue reading</a></p>
                    }
                <?php endwhile; ?>
                <?php else : ?>
                    Nothing Found Stuff goes here
                <?php endif; ?>
  2. davidsword
    Member
    Posted 2 years ago #

    at first glance: gotta wrap your PHP code in <?php .. ?> tags

    <?php if ( has_post_format( 'status' )) { ?>

    ...

    <?php }
                    else { ?>

    ...

    <?php } ?>
  3. 3Plumes
    Member
    Posted 2 years ago #

    Ahhh, thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic