• In Settings/Reading we’ve set up a static Front Page and a Posts Page named News:
    http://citizens4sbcc.org/news/

    Question: how do we get Summaries rather than full Posts on –only– this News Page? That is, each Post and Page is currently full-length everywhere else on the site and we want each one displayed that way. We do not want auto-summary on any other Pages or Posts. Only when Posts are displayed on the Posts Page (News) do we want them automatically truncated to a few lines with a More… link. Is there a way to do this?

Viewing 14 replies - 1 through 14 (of 14 total)
  • Use </php the_excerpt();?> instead of <?php the_content();?> in your theme’s index.php template file.

    Thread Starter citizens4sbcc

    (@citizens4sbcc)

    Cool to get your help so fast! Makes sense to me, but I’m concerned that doing this would make for “More…” tags on every Page & Post. Also, that “the_…” string’s not in the index.php file in this theme (Graphene 1.0). Aside from comments, just these three lines:
    <?php get_header(); ?>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    I went ahead and tried adding this to the bottom of the index.php file:
    </php the_excerpt();?>
    No difference. I then tried this:
    </php get_excerpt();?>
    No difference.

    Ideas?

    Thread Starter citizens4sbcc

    (@citizens4sbcc)

    Noticed that the two strings I tried started with “</” and the ones in the index.php start with “<?” so I tried again with that and still no joy.

    Try looking in header.php for an included file,. Your index.php template will be including a lot more than just those 3 files.

    In loop.php about line 66

    <?php the_content(__('Read the rest of this entry »','graphene')); ?>

    Change “Remark” the_content() and add the_excerpt(), do not delete in case you want to roll back

    <?php //REMARKED THIS LINE the_content(__('Read the rest of this entry »','graphene')); ?>
    <?php the_excerpt(); ?>

    HTH

    David

    Thread Starter citizens4sbcc

    (@citizens4sbcc)

    Adeptris, we’re definitely in the ballpark! Doing as you suggest did in fact create a “Continue Reading” prompt on the News Page. Two downsides though: 1. It munges all the excerpt text together, wiping out all formatting so it’s all but impossible to read. 2. It does the same to EVERY Page and Post on the site.

    Can it be that my problem has to do with this being a conditional if/then? Here’s the surrounding code in the loop.php file:

    <?php /* Post content */ ?>
                        <div class="entry-content clearfix">
                            <?php if (!is_search() && !is_archive()) : ?>
                            <?php the_content(__('Read the rest of this entry &raquo;','graphene')); ?>
                            <?php else : ?>
                                <?php the_excerpt(); ?>
                            <?php endif; ?>

    Do I need another if/then to turn off the Graphene line as you did but ONLY for the News Page (WP Posts Page), and then add in that “the_content” line in the index.php file? Then some other code to restore the Post formatting in the excerpts?

    Sure seems like this is a problem specific to the Graphene theme, so I’ve posted a query on the new forum there too but so far no reply.

    Thanks for your help! You’ve given me hope of eventually figuring this out, and then I can post the solution on both forums so others can gain this functionality.

    Untested try post_name or post_nicename

    <?php if (!$post->post_name=='news' && !is_search() && !is_archive()) : ?>

    HTH

    David

    Thread Starter citizens4sbcc

    (@citizens4sbcc)

    I’ll try to figure out what file post_name is in and what it does, and meanwhile it’s been years since any programming so I’m wondering if the final code excerpt would look like this:

    <?php /* Post content */ ?>
                        <div class="entry-content clearfix">
     <?php if (!$post->post_name=='news' && !is_search() && !is_archive()) : ?>
     <?php the_excerpt(); ?>
     <?php else : ?>
                            <?php if (!is_search() && !is_archive()) : ?>
                            <?php the_content(__('Read the rest of this entry »','graphene')); ?>
                            <?php else : ?>
                                <?php the_excerpt(); ?>
                            <?php endif; ?>
     <?php endif; ?>

    Thread Starter citizens4sbcc

    (@citizens4sbcc)

    I wonder if Graphene already has a nice way to format excerpts, and I just haven’t found where to turn it on. Near the end of the functions.php file there’s this:

    if (!function_exists('graphene_continue_reading_link')) :
        function graphene_continue_reading_link() {
            return ' <a href="'. get_permalink() . '">' . __( 'Continue reading »', 'graphene' ) . '</a>';
        }
    endif;
    
    /**
     * Replaces "[...]" (appended to automatically generated excerpts) with an ellipsis and graphene_continue_reading_link().
     * Based on the function from Twenty Ten theme.
     *
     * To override this in a child theme, remove the filter and add your own
     * function tied to the excerpt_more filter hook.
     *
     * @since Graphene 1.0.8
     * @return string An ellipsis
     */
    function graphene_auto_excerpt_more( $more ) {
        return '…' . graphene_continue_reading_link();
    }
    add_filter('excerpt_more', 'graphene_auto_excerpt_more' );

    OK, I’ve searched every imaginable file on the string “excerpt” and don’t find a place where the_excerpt is defined. I guess either it’s a PHP function or is in a file I can’t access via the WordPress Appearance/Editor admin screen. So maybe I can replace the_excerpt with excerpt_more or with graphene_auto_excerpt_more in the code snippet above to get better formatting? Am I totally lost?

    Thread Starter citizens4sbcc

    (@citizens4sbcc)

    I tried your post_nice trick and it did nothing so I tried post_nicename and it worked on News, but again it just shows every Page and Post in mangled summary format so maybe I did it wrong. Here’s what I tried:

    <?php /* TEST FOR NEWS SUMMARIES */ ?>
    <?php if (!$post->post_nicename=='news' && !is_search() && !is_archive()) : ?>
    <?php the_excerpt(); ?>
    <?php else : ?>
                            <?php if (!is_search() && !is_archive()) : ?>
                            <?php the_content(__('Read the rest of this entry »','graphene')); ?>
                            <?php else : ?>
                                <?php the_excerpt(); ?>
                            <?php endif; ?>
    <?php endif; ?>
    <?php /* END TEST */ ?>

    What that code is doing is using the Graphene Continue Reading function for the excerpt more.

    This is nothing to do with your original question:

    Question: how do we get Summaries rather than full Posts on -only- this News Page?

    The answer to this is in the loop.php file which you should be able to see in the editor.

    Although I strongly suggest that if you have ftp you setup a local environment to edit and test changes, you could lock yourself out of the admin area with a syntax error, editing live files.

    In the loop.php find line 65:
    <?php if (!is_search() && !is_archive()) : ?>
    change to:
    <?php if (!$post->post_name=='news' && !is_search() && !is_archive()) : ?>

    post_name is the page slug, this is what you should have after the change:

    <?php if (!$post->post_name=='news' && !is_search() && !is_archive()) : ?>
         <?php the_content(__('Read the rest of this entry »','graphene')); ?>
    <?php else : ?>
         <?php the_excerpt(); ?>
    <?php endif; ?>

    However lets put the Brakes On!
    Looking at the page content this might not be the best way forward, excerpt does not return images, and your posts would not look nice without the images the list text would also look strange.

    It would be far cleaner if you accept that site-wide some posts would look better with the more link, then just edit the posts in the editor and add in the more option.

    Looking at the data after the persons ‘Name’ or before the line ‘Individual Endorsements’ would be ok.
    Insert a line where you want the more text.
    In the visual view Alt+Shift+T or click the icon next to the link
    In html view insert a line where you want the more text, and enter <!--more-->

    Now you control where the more link is output on the pages, your idea would have been ok if these were normal text posts but with the images and lists the editor option is far cleaner.

    HTH

    David

    Thread Starter citizens4sbcc

    (@citizens4sbcc)

    Yeh, using the More tag would make for a clean site. Troubles are two: 1. I don’t want to manually tag every post the other volunteers make. 2. We don’t want every Post to have a more tag, but we DO want everything on the News Page to be in summary format. sigh…

    You’re right also of course about the perils of live editing, but again I don’t have ftp or any other access to the (ick) GoDaddy account this site is hosted on. Maybe I could get that, but having once futzed around with several static and dynamic (Drupal mostly) sites hosted by them, I’d prefer to just hide or leave town for a couple of months. 🙂

    I had an idiotic Aha moment realizing the bang is a NOT (!$post…) but my thick skull is still not allowing me to grok how this thing works. As you semi-predicted, swapping out the “<?php if…” line with yours produced a site-wide glitch:
    Parse error: syntax error, unexpected T_ENDWHILE in /home/content/91/5424091/html/CITIZENSFORSBCC/wordpress/wp-content/themes/graphene/loop.php on line 109
    Luckily I had another tab open in the browser with the editor window open on the loop file so I just changed it back and the site’s happy again.

    So far I’ve found several ways of making every Page/Post be excerpts, but no way of making only the News Page be so. I even tried turning off the Settings/Reading/Posts page: News option and inserting some code into the News Page, but of course that just displays the code without executing it.

    Guess there’s no way to get there from here, so thanks for your help and patience.

    Thread Starter citizens4sbcc

    (@citizens4sbcc)

    OK, duh! I went ahead and inserted More links using the Visual interface and the original Posts show the complete text. Only in the News Page version do they have the “Read the rest of this entry »” link, and that takes you to the original Post at the location of the tag. Slick! If we only do that on the few really long Posts, it will probably work fine.

    Thanks everyone for your responses. As the Graphene theme author, I would also recommend the solution that Adeptris suggested.

    PS: My apologies for not responding earlier. I have very, very little free time at the moment. This is the busiest time of the year for me.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Posts Page – Summaries?’ is closed to new replies.