WordPress.org

Support

Support » Themes and Templates » Customize P2 theme to display teasers on homepage

Customize P2 theme to display teasers on homepage

  • 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.

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

    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.

    Glad you got it working! 🙂

    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.

    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.

    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

    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

    cancel that… I got excerpt on both single and index 🙁

    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 : ?>

    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 : ?>

    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

    @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]

    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

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Customize P2 theme to display teasers on homepage’ is closed to new replies.
Skip to toolbar