Forums

[resolved] Using a conditional instead of separate single.php page (4 posts)

  1. ppeter
    Member
    Posted 4 years ago #

    Hi.
    I'm very new to WordPress and I'm not good with the function etc. Now, I have used the_excerpt() instead of the_content() which has obviously put the excerpt everywhere. The solution I've found by searching around is to either add a single.php file or use a conditional in index.php to choose to display the excerpt on the permalink page.

    I get the single.php option, which I'd rather not do, but I haven't a clue on using the conditional and couldn't find out how to do that - any ideas?

    Many thanks in advance, Phil

  2. TechGnome
    Moderator
    Posted 4 years ago #

    In a word: The Codex (ok, so it was two).
    http://codex.wordpress.org/Conditional_Tags

    -tg

  3. ppeter
    Member
    Posted 4 years ago #

    EDIT: Thanks TG!

    Okay I figured it out. For anyone else wanting to know this the solution is as follows...
    You simply replace the_excerpt() with this conditional:

    if (is_single()){
    the_content();

    } else {
    the_excerpt();
    }

    is_single() returns TRUE when you are viewing a single post, so you can then show the full text but show the excerpt on all other pages.

    Phil

  4. TechGnome
    Moderator
    Posted 4 years ago #

    To make it easier for those that follow, could you please mark the thread as Resolved? There's a link to click on at the top that will do that.

    Thanks.
    Tg

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags