Forums

Making an exception to blog showing excerpts (12 posts)

  1. alastairhumphreys
    Member
    Posted 2 years ago #

    Hi,
    My blog shows excerpts of each post. I would like that the first post is shown in its entirety, but that all the others remain with just excerpts.
    I don't mean making one post sticky. When I add a new blog post it would replace the previous one in being in its entirety...
    I hope you can help with this.
    Thanks,
    Al

    http://www.alastairhumphreys.com

  2. vtxyzzy
    Member
    Posted 2 years ago #

    This begs the question 'What do you want to do on pages other than the first?'. If you want only the first page to show the first post fully, code similar to this might work for you:

    <?php
    $paged = (intval(get_query_var('paged'))) ? intval(get_query_var('paged')) : 1;
    $count = 0;
    if (have_posts()) : while (have_posts()) : the_post();
       if ($paged == 1 && ++$count == 1) {
          the_content();
       } else {
          the_excerpt();
       }
       // Other stuff for this post
    endwhile; endif;
    ?>

    If you want the same format on all pages, take out the test for $paged == 1.

  3. alastairhumphreys
    Member
    Posted 2 years ago #

    Thanks very much for this really helpful reply.
    Can I please just ask you to tell me where I put this?! I'm a bit out of my depth here...
    Thank you,
    Al

  4. vtxyzzy
    Member
    Posted 2 years ago #

    OK - I just installed and looked at the thematic theme which I think you are using. If that is the case, you need to edit library/extensions/content-extenstions.php, function thematic_content().

    I can't test this easily, but I think this will work:

    Change this:

    function thematic_content() {
       if (is_home() || is_front_page()) {
          $content = 'full';
       } elseif (is_single()) {

    to this:

    function thematic_content() {
       global $count;
       if (is_home() || is_front_page()) {
          if ( $count == 1 ) {
             $content = 'excerpt';
          } else {
             $content = 'full';
          }
       } elseif (is_single()) {
  5. alastairhumphreys
    Member
    Posted 2 years ago #

    thank you so much for your help on this.
    I have replaced the code you suggested but it does not appear to have changed anything...
    Sorry to be a pain!

  6. vtxyzzy
    Member
    Posted 2 years ago #

    That's OK. I think I got the full/excerpt backwards, and I am guessing that $count is not set where it can be a global. Please try this instead:

    function thematic_content() {
       global $my_page_count;
       if (is_home() || is_front_page()) {
          if ( ++$my_page_count == 1 ) {
             $content = 'full';
          } else {
             $content = 'excerpt';
          }
       } elseif (is_single()) {
  7. vtxyzzy
    Member
    Posted 2 years ago #

    Just another note - to be safe from future thematic upgrades, you should make a child theme as explained here, create your own functions.php, copy the thematic_content() function into it, and make the modifications to the child functions.php.

  8. alastairhumphreys
    Member
    Posted 2 years ago #

    I've tried this and it didn't work either - sorry about this! I'm sure you've nearly cracked it though!
    Al

  9. vtxyzzy
    Member
    Posted 2 years ago #

    One final change - change the word 'global' to 'static' and you should have it.

  10. alastairhumphreys
    Member
    Posted 2 years ago #

    sorry - not working quite yet!! You're going to be wishing you had never begun helping me...
    Al

  11. vtxyzzy
    Member
    Posted 2 years ago #

    I don't know what else to do - the code works for me in the Thematic theme.

    Perhaps if you posted your thematic/library/extensions/content-extensions.php (or from the child theme if you made one) in the pastebin, and posted a link to it here, I could take a look.

  12. alastairhumphreys
    Member
    Posted 2 years ago #

    Here is the link: http://wordpress.pastebin.com/rtK8tdEm

    Thank you - I really appreciate this.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags