Hmm..I didn’t explain that very well.
Current situation:
‘
<?php if ( !is_single() && ! is_page()) { ?>
<?php the_excerpt();?>
<?php if (!is_page()) {?>
“>[read it!]
<?php } } ?>
‘
Desired situation:
‘
<?php if ( !is_single() && ! is_page()) { ?>
IF POST HAS AN EXCERPT {
<?php the_excerpt();?>
<?php if (!is_page()) {?>
“>[read it!]
}
ELSE {
DISPLAY THE ENTIRE POST
}
<?php } } ?>
Ugly, but you get the idea, I hope. It’s the bits in CAPS that I can’t figure out.
And no, I’m not a coder. Can you tell? 🙂
This might work, but I’m not sure:
<?php
if ($post->excerpt == '') {
the_content();
}else {
the_excerpt();
}
?>
It checks the excerpt field, if it’s empty, then it’ll display the content, otherwise it’ll display the excerpt itself.
-tg
Thanks for the code, I see what you’re going for, but the IF always evaluates to the content.
The full content is being displayed regardless of the presence or absence of an excerpt and the excerpt is never being displayed.
What does an empty excerpt look like? Perhaps ” isn’t the right value?
Best way to do this… find the functions-post.php file (it’s in the wp-includes folder). Open it up and look for the_excerpt. Look to see how it does the check, and just mimic that.
-tg
That helped, thanks! Here’s what I ended up with”
‘<!– Check what to display – excerpt or content–>
<?php
if (empty($post->post_excerpt)) {
the_content();
}else {
the_excerpt();?>
“>[read the rest…]
<?
}
?>
<!– check –>
‘
Can you tell me which file you are editing with this code? It is a solution I am looking for, but not sure which file to edit.
Thanks
i would use the same system in my blog…how can i modify the loop code in the archive ?
<?php while (have_posts()) : the_post(); ?>
<?php the_content('Read on »'); ?>
<h2 class="storytitle" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<div class="date">Published on <?php the_time('l') ?>, <?php the_time('F') ?> <?php the_time('jS') ?>, <?php the_time('Y') ?> | <?php comments_popup_link(__('No Comments'), __('1 Comment'), __('% Comments')); ?> <?php wp_link_pages(); ?> <?php edit_post_link('Edit'); ?> </div>
<!--
<?php trackback_rdf(); ?>
-->
<?php endwhile; else: ?>
<h2>Not Found</h2>
<p><?php _e("Sorry, but you are looking for something that isn't here."); ?></p>
<?php endif; ?>