WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] WordPress 3.5 Page of Posts (4 posts)

  1. amandastock
    Member
    Posted 1 year ago #

    Hi!

    I've created a custom blog layout using home.php based off of index.php.
    Now, I am trying to create a page of posts that displays like the standard index.php.

    I've tried using the page of posts method from the codex. I've tried copying page.php and using that. I've tried copying index.php and using that. However, what happens is this: whatever page the code is applied to it is pulling the information of that page rather than from the posts. For example, I created a page called Blog and instead of showing 10 blog posts, it show one post that says:

    Blog

    Leave a reply
    This entry was posted on February 9, 2013. Edit

    So its pulling the information for the page rather than posts.

    Here is the blog page template


    <?php
    /**
    * Template Name: Blog Page
    *
    * This is the template that displays all pages by default.
    * Please note that this is the WordPress construct of pages
    * and that other 'pages' on your WordPress site will use a
    * different template.
    *
    * @package WordPress
    * @subpackage Twenty_Twelve
    * @since Twenty Twelve 1.0
    */

    get_header(); ?>

    <div id="primary" class="site-content">
    <div id="content" role="main">

    <?php if ( have_posts() ) : ?>

    <?php /* Start the Loop */ ?>
    <?php while ( have_posts() ) : the_post(); ?>
    <?php get_template_part( 'content', get_post_format() ); ?>
    <?php endwhile; ?>

    <?php twentytwelve_content_nav( 'nav-below' ); ?>

    <?php else : ?>

    <article id="post-0" class="post no-results not-found">

    <?php if ( current_user_can( 'edit_posts' ) ) :
    // Show a different message to a logged-in user who can add posts.
    ?>
    <header class="entry-header">
    <h1 class="entry-title"><?php _e( 'No posts to display', 'twentytwelve' ); ?></h1>
    </header>

    <div class="entry-content">
    <p><?php printf( __( 'Ready to publish your first post? Get started here.', 'twentytwelve' ), admin_url( 'post-new.php' ) ); ?></p>
    </div><!-- .entry-content -->

    <?php else :
    // Show the default message to everyone else.
    ?>
    <header class="entry-header">
    <h1 class="entry-title"><?php _e( 'Nothing Found', 'twentytwelve' ); ?></h1>
    </header>

    <div class="entry-content">
    <p><?php _e( 'Apologies, but no results were found. Perhaps searching will help find a related post.', 'twentytwelve' ); ?></p>
    <?php get_search_form(); ?>
    </div><!-- .entry-content -->
    <?php endif; // end current_user_can() check ?>

    </article><!-- #post-0 -->

    <?php endif; // end have_posts() check ?>

    </div><!-- #content -->
    </div><!-- #primary -->

    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    and here is the content.php which it references:


    <?php
    /**
    * The default template for displaying content. Used for both single and index/archive/search.
    *
    * @package WordPress
    * @subpackage Twenty_Twelve
    * @since Twenty Twelve 1.0
    */
    ?>

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
    <div class="featured-post">
    <?php _e( 'Featured post', 'twentytwelve' ); ?>
    </div>
    <?php endif; ?>
    <header class="entry-header">
    <?php the_post_thumbnail(); ?>
    <?php if ( is_single() ) : ?>
    <h1 class="entry-title"><?php the_title(); ?></h1>
    <?php else : ?>
    <h1 class="entry-title">
    " title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?>
    </h1>
    <?php endif; // is_single() ?>
    <?php if ( comments_open() ) : ?>
    <div class="comments-link">
    <?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentytwelve' ) . '</span>', __( '1 Reply', 'twentytwelve' ), __( '% Replies', 'twentytwelve' ) ); ?>
    </div><!-- .comments-link -->
    <?php endif; // comments_open() ?>
    </header><!-- .entry-header -->

    <?php if ( is_search() ) : // Only display Excerpts for Search ?>
    <div class="entry-summary">
    <?php the_excerpt(); ?>
    </div><!-- .entry-summary -->
    <?php else : ?>
    <div class="entry-content">
    <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentytwelve' ) ); ?>
    <?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after' => '</div>' ) ); ?>
    </div><!-- .entry-content -->
    <?php endif; ?>

    <footer class="entry-meta">
    <?php twentytwelve_entry_meta(); ?>
    <?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?>
    <?php if ( is_singular() && get_the_author_meta( 'description' ) && is_multi_author() ) : // If a user has filled out their description and this is a multi-author blog, show a bio on their entries. ?>
    <div class="author-info">
    <div class="author-avatar">
    <?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'twentytwelve_author_bio_avatar_size', 68 ) ); ?>
    </div><!-- .author-avatar -->
    <div class="author-description">
    <h2><?php printf( __( 'About %s', 'twentytwelve' ), get_the_author() ); ?></h2>
    <p><?php the_author_meta( 'description' ); ?></p>
    <div class="author-link">
    " rel="author">
    <?php printf( __( 'View all posts by %s <span class="meta-nav">→</span>', 'twentytwelve' ), get_the_author() ); ?>

    </div><!-- .author-link -->
    </div><!-- .author-description -->
    </div><!-- .author-info -->
    <?php endif; ?>
    </footer><!-- .entry-meta -->
    </article><!-- #post -->

    I know it used to be different than this, so maybe I am not seeing something. Any ideas?

  2. amandastock
    Member
    Posted 1 year ago #

    FYI: copying the code put in links above instead of displaying the entire code. but where those links are is actually an a href not messed up code in the template

  3. amandastock
    Member
    Posted 1 year ago #

  4. amandastock
    Member
    Posted 1 year ago #

    Marked as solved, using the blog post above.

Topic Closed

This topic has been closed to new replies.

About this Topic