WordPress.org

Ready to get started?Download WordPress

Forums

Hiding Post bodys... (8 posts)

  1. AJ
    Member
    Posted 9 years ago #

    I have a strange problem... basically, I want to take the piece of code that tells wp-comments when to display (ie when you click on the permalink) and use that to only display the post body when you click the permalink, if that makes sense...

    So, what is the part of the file that checks for the ?p=xyz or whatever...

    Thanks all

    AJ

  2. TechGnome
    Moderator
    Posted 9 years ago #

    What version are you using? There's a way to do that, but it depends if you are using 1.2.x or 1.[3|5]

    Tg

  3. Nick Momrik
    Member
    Posted 9 years ago #

    An easy way would be to place whatever code you only want to see on a permalinked page in between these....
    <?php if (!$single) { ?>
    and
    <?php } ?>

    What that does is if it's not a single post page, the code in between is run. The code in between can be simply the portion that calls the post body (function the_content) or whatever you want.

  4. AJ
    Member
    Posted 9 years ago #

    it's 1.2.2... TechGnome...

    MtDew, that looks like a nice way to do it!

    Thanks for the quick response guys!

  5. TechGnome
    Moderator
    Posted 9 years ago #

    just to expound on MDV's answer, the way I'd do it (and have done it) is like this :
    <?php if(!$single) {
    the_excerpt();
    }else{
    the_content();
    }
    ?>

    That gives the excerpt text on the main page, but gives the full text on individual pages.

    Tg

  6. Nick Momrik
    Member
    Posted 9 years ago #

    TechGnome...why not save an extra character. ;-)

    <?php if($single) {
    the_content();
    }else{
    the_excerpt();
    }
    ?>

  7. TechGnome
    Moderator
    Posted 9 years ago #

    6 of one, half-dozen of another. Potayto, potato. What ever boats your float.

    In terms of optimization, it's "Faster" using !. since that condition will execute more often than not, it doesn't have to jump as far to execute the next line... since 1) were' talking about micro milli seconds, 2) PHP is a scripted language - it proly doesn't matter that much. It's just my day job creaping in on me.

    Tg

  8. Nick Momrik
    Member
    Posted 9 years ago #

    hehe...just giving you a hard time. ;)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.