WordPress.org

Ready to get started?Download WordPress

Forums

Customize P2 theme to display teasers on homepage (14 posts)

  1. deanloh
    Member
    Posted 4 years ago #

    I love P2 theme! I will love it even more if there is a way to customize the theme to display only teaser automatically on homepage, by that I mean: first nn of words.

    I'm still new to WordPress and I know there is a field for teaser in posting form, but I'm just hoping to simplify the workflow.

  2. Kate
    Member
    Posted 4 years ago #

    As you may know, the standard for displaying only an excerpt in WordPress is:
    <?php the_excerpt(); ?>

    That's used in place of:
    <?php the_content(); ?>

    However, that's a somewhat limited route. Personally, when I need to do more with the excerpt, I like to use the Advanced Excerpt plugin:
    http://wordpress.org/extend/plugins/advanced-excerpt/

    I've always had good results with it.

  3. jmunn
    Member
    Posted 4 years ago #

    Thanks Katendarcy. This was a bit tricky with the P2 theme in entry.php but I got it working to just display excerpts on the front page but nowhere else.

  4. Kate
    Member
    Posted 4 years ago #

    Glad you got it working! :)

  5. rhinelephonkey
    Member
    Posted 4 years ago #

    jmunn...can you post what you did. I am trying the same and have been playing around with the entry.php as well with no luck.

  6. jmunn
    Member
    Posted 4 years ago #

    Well, I'm just using "posts", no new buttons for quotes or links. So far this is working to show the excerpt except when you click on the link.

    change from

    <?php if ( 'status' == p2_get_the_category() || 'link' == p2_get_the_category() ) : ?>
    
    			<?php p2_title( '<h2>','</h2>' ); ?>
    
    			<?php the_content( __( '(More ...)' , 'p2' ) ); ?>
    
    		<?php elseif ( 'quote' == p2_get_the_category() ) : ?>
    
    			<?php p2_title( '<h2>','</h2>' ) ?>
    
    			<blockquote>
    				<?php p2_quote_content() ?>
    			</blockquote>
    
    		<?php elseif ( 'post' == p2_get_the_category() ) : ?>
    
    			<?php p2_title( '<h2>','</h2>' ) ?>
    			<?php the_content( __( '(More ...)' , 'p2' ) ); ?>
    
    		<?php else : ?>
    
    			<?php p2_title( '<h2>','</h2>' ); ?>
    
    			<?php the_content( __( '(More ...)' , 'p2' ) ); ?>
    
    		<?php endif; ?>

    to

    <?php if (is_single() || is_page()) : ?>
    
    			<?php p2_title( '<h2>','</h2>' ); ?>
    
                <?php the_content( __( '(More ...)' , 'p2' ) ); ?>
    
    			<?php else : ?>
    
    			<?php p2_title( '<h2>','</h2>' ); ?>
    
    <?php the_excerpt( __( '(More..)' , 'p2' ) ); ?>
    
    <?php endif; ?>

    So far it works.. but I barely know what I'm doing.

  7. jmunn
    Member
    Posted 4 years ago #

    If you are using @ mentions you might want to add this to functions.php after the p2_at_names function so the links show up. ... I think

    if( !is_admin() ) add_filter( 'the_excerpt', 'p2_at_names' ); // hook into content

  8. DJTwittr
    Member
    Posted 4 years ago #

    jmun, worked like a champ however all I did was replace
    <?php the_content( __( '(More ...)' , 'p2' ) ); ?>

    with

    <?php the_excerpt( __( '(More..)' , 'p2' ) ); ?>

    and added if( !is_admin() ) add_filter( 'the_excerpt', 'p2_at_names' ); // hook into content

    at about line 87 in functions.php

  9. DJTwittr
    Member
    Posted 4 years ago #

    cancel that... I got excerpt on both single and index :(

  10. Scott Kingsley Clark
    Member
    Posted 3 years ago #

    I made a simple modification since only Posts in my P2 theme need this:

    <?php elseif ( 'post' == p2_get_the_category() ) : ?>
    
    			<?php p2_title(); ?>
    			<?php the_content( __( '(More ...)' , 'p2' ) ); ?>
    
    		<?php else : ?>

    to:

    <?php elseif ( 'post' == p2_get_the_category() ) : ?>
    
    			<?php p2_title(); ?>
    			<?php if( is_single() ){ the_content( __( '(More ...)' , 'p2' ) ); } else { the_excerpt(); } ?>
    
    		<?php else : ?>
  11. Scott Kingsley Clark
    Member
    Posted 3 years ago #

    Actually, this change ended up working better for me:

    <?php elseif ( 'post' == p2_get_the_category() ) : ?>
    
    			<?php p2_title(); ?>
    			<?php the_content( __( '(More ...)' , 'p2' ) ); ?>
    
    		<?php else : ?>

    to:

    <?php elseif ( !is_singular() ) : ?>
    
    			<?php p2_title(); ?>
    			<?php the_excerpt(); ?>
    
    		<?php else : ?>
  12. ozbcoz
    Member
    Posted 3 years ago #

    thanks jmunn - your version worked perfectly for me - now I am looking for a way to paginate comments on home page after n comments (similar to facebook)

    cheers

    Jim

  13. intenseblog
    Member
    Posted 3 years ago #

    @ozbcoz: WordPress has its built in function to help you do that, just go to wp-admin/options-discussion.php and check the line with: "Break comments into pages with..."
    Cheer :)
    [sig moderated as per the Forum Rules]

  14. ozbcoz
    Member
    Posted 3 years ago #

    yep - saw that - but i was looking to do more along the lines of say have the latest 3 or 4 comments show under the post on the home page (as you see on facebook) and then as std be able to link to the article and see the full post and comments (paginated in the std wordpress way if required).

    hope that's clearer

    cheers

    Jim

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags