• Resolved Christine357

    (@christine357)


    So I recently implemented a template called Page-Of-Posts Template for Twenty Twelve that I got from http://www.transformationpowertools.com/wordpress/page-of-posts-template-for-twenty-twelve and now I am working on getting it customized. One thing left to do is have it so the posts only show the excerpt. I know that one way to do this is in content.php but this would change my main blog page as well and I only want it done on my custom blog page. I did find this codex that I think is what I need:

    Access all post data
    Some post-related data is not available to get_posts by default, such as post content through the_content(), or the numeric ID. This is resolved by calling an internal function setup_postdata(), with the $post array as its argument:

    <?php
    $args = array( 'posts_per_page' => 3 );
    $lastposts = get_posts( $args );
    foreach ( $lastposts as $post ) :
      setup_postdata( $post ); ?>
    	<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    	<?php the_content(); ?>
    <?php endforeach;
    wp_reset_postdata(); ?>

    The line with <?php the_content(); ?> when changed to the_excerpt from content.php will only show the excerpts. So I was wondering how I might implement this on my page?

Viewing 4 replies - 1 through 4 (of 4 total)
  • assuming that you don’t use post formats, you could replace this line
    <?php get_template_part( 'content', get_post_format() ); ?>
    with the cleaned-up corresponding code from content.php;
    for instance:

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    		<header class="entry-header">
    			<?php the_post_thumbnail(); ?>
    			<h1 class="entry-title">
    				<a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
    			</h1>
    		</header><!-- .entry-header -->
    
    		<div class="entry-summary">
    			<?php the_excerpt(); ?>
    		</div><!-- .entry-summary -->
    
    		<footer class="entry-meta">
    			<?php twentytwelve_entry_meta(); ?>
    			<?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?>
    		</footer><!-- .entry-meta -->
    	</article><!-- #post -->

    Thread Starter Christine357

    (@christine357)

    I appreciate the feedback but I’m sorry, I’m still new to how all this code works. I’m unsure what you’re saying to replace that line with from that posted code or how to adjust my code similarly since I don’t see the relation. Could you be more specific?

    replace that line with the posted block of code.

    Thread Starter Christine357

    (@christine357)

    Ohh I see. That just didn’t make sense in my head how it could all replace that one line haha. But I see now, this works, thank you!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Excerpt on alt Blog’ is closed to new replies.