• 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

    https://www.alastairhumphreys.com

Viewing 11 replies - 1 through 11 (of 11 total)
  • 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.

    Thread Starter alastairhumphreys

    (@alastairhumphreys)

    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

    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()) {
    Thread Starter alastairhumphreys

    (@alastairhumphreys)

    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!

    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()) {

    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.

    Thread Starter alastairhumphreys

    (@alastairhumphreys)

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

    One final change – change the word ‘global’ to ‘static’ and you should have it.

    Thread Starter alastairhumphreys

    (@alastairhumphreys)

    sorry – not working quite yet!! You’re going to be wishing you had never begun helping me…
    Al

    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.

    Thread Starter alastairhumphreys

    (@alastairhumphreys)

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

    Thank you – I really appreciate this.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Making an exception to blog showing excerpts’ is closed to new replies.