How to Detect If the "optional excerpt" is empty or not? (3 posts)

  1. marclin
    Posted 8 years ago #

    If "optional excerpt" has typed something, show the_excerpt. (don't show the_content()), otherwise show the_content();

    Is that doable?

  2. Kafkaesqui

    Posted 8 years ago #

    if( $post->post_excerpt ) {
    } else {
  3. mores
    Posted 7 years ago #

    Thanks Kafkaesqui ... that helped me with another issue. I wanted to use the permalink only if a post actually contained content ... otherwise just write the title.

    <?php global $post;
    $myposts = get_posts('numberposts=20&'."category=$category->id");
    foreach($myposts as $post) : setup_postdata($post);
    	if( $post->post_content ) { ?>
    		<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <span class="datetime">(<?php the_time('j. F Y'); ?>)</span></li>
    	<?php } else { ?>
    		<li><?php the_title(); ?> <span class="datetime">(<?php the_time('j. F Y'); ?>)</span></li>
    	<?php } ?>
    <?php endforeach; ?>

    I'm posting it here just in case someone else is looking for something similar.

Topic Closed

This topic has been closed to new replies.

About this Topic