• Resolved Meduncho

    (@meduncho)


    Hello,
    What I am trying to achieve is to show the content I enter in the field “excerpt” when creating a post, as additional info under the title link on a page. What I need is for it to show only when there is something filled in the excerpt field. Right now it works but it generates and shows automaticly excerpt for the posts that I haven’t entered anything for excerpt in the post page. My loop code looks like this:

    <h3 ><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
    <p class="excstl"><?php remove_filter('the_excerpt', 'wpautop'); ?><?php the_excerpt(); ?></p>

    My theme is based on Twenty ten.

    Also how can I apply the css class to the excerpt, so when there is no content in it I don’t load the <p class=”excstl”> </p> around it ?

    Please help, trying to find a solution in forums in google for over 2 hours now.

    Thanks for your time.

Viewing 3 replies - 1 through 3 (of 3 total)
  • According to the codex entry, get_the_excerpt() will solve both of your problems as it (a) will return an empty string if not manually defined and (b) returns just the excerpt without any markup (so you can pass it into a variable and test to see if its empty).

    If that doesn’t work, perhaps you should consider using Custom Fields.

    Hope that helps

    Peter

    <?php if( $post->post_excerpt ) { ?>
    <p class="excstl"><?php echo $post->post_excerpt; ?></p>
    <?php } ?>
    Thread Starter Meduncho

    (@meduncho)

    Thank you both for the help provided,

    alchymyth’s code worked flawlessly, cheers

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show only excerpt that is manually filled from the field under the post’ is closed to new replies.