WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Blog page not showing posts (10 posts)

  1. beholdadmin
    Member
    Posted 1 year ago #

    I am making a custom theme for my site and having issues with my blog posts not showing up on my blog page. I made a page titled 'blog' and using the template name Blog, file name '_blog.php' – I have a few test posts made and 'published' but they are not being shown or pulled to display on my blog page. When I edit my 'Reading Settings' with 'Posts Page:' set to 'Blog,' my blog page at http://siteurl.com/blog displays my index.php page.

    Any help would be appreciated. I can post my php to view if needed.

    Thanks in advance!

  2. wpismypuppet
    Member
    Posted 1 year ago #

    Log into the admin section and go into "settings->reading". Change "Front page display" to "A static page" and for the "Posts page:" choose your blog page.

  3. beholdadmin
    Member
    Posted 1 year ago #

    Hi, Thanks for the comment. I had already done that. My front page was selected with 'A static page' and my Posts page selected to my 'Blog' page. However, when my Posts page is selected to my 'Blog' page the blog gets redirected to my index.php

  4. wpismypuppet
    Member
    Posted 1 year ago #

    Actually, I apologize. When you do what I mentioned, WordPress ignores all page templates and forces the index.php file to be used. And this makes sense since you already had these settings in place. Do the opposite of what I said and set that field back to "--- Select ---". Then you'll use your page template instead.

  5. beholdadmin
    Member
    Posted 1 year ago #

    Yes, that's what I had to revert back to. The default --Select-- option is currently in place but I can't seem to get any posts to display on the Blog page :/ I was thinking it may have to do with my PHP??

  6. wpismypuppet
    Member
    Posted 1 year ago #

    Ok... please show the code. :)

  7. beholdadmin
    Member
    Posted 1 year ago #

    <?php /* The Loop — with comments! */ ?>
    <?php while ( have_posts() ) : the_post() ?>
    
    <?php /* Create a div with a unique ID thanks to the_ID() and semantic classes with post_class() */ ?>
                    <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <?php /* an h2 title */ ?>
                        <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( __('Permalink to %s', 'your-theme'), the_title_attribute('echo=0') ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    
    <?php /* Microformatted, translatable post meta */ ?>
                        <div class="entry-meta">
                            <span class="meta-prep meta-prep-author"><?php _e('By ', 'your-theme'); ?></span>
                            <span class="author vcard"><a class="url fn n" href="<?php echo get_author_link( false, $authordata->ID, $authordata->user_nicename ); ?>" title="<?php printf( __( 'View all posts by %s', 'your-theme' ), $authordata->display_name ); ?>"><?php the_author(); ?></a></span>
                            <span class="meta-sep"> | </span>
                            <span class="meta-prep meta-prep-entry-date"><?php _e('Published ', 'your-theme'); ?></span>
                            <span class="entry-date"><abbr class="published" title="<?php the_time('Y-m-d\TH:i:sO') ?>"><?php the_time( get_option( 'date_format' ) ); ?></abbr></span>
                            <?php edit_post_link( __( 'Edit', 'your-theme' ), "<span class=\"meta-sep\">|</span>\n\t\t\t\t\t\t<span class=\"edit-link\">", "</span>\n\t\t\t\t\t" ) ?>
                        </div><!-- .entry-meta -->
    
    <?php /* The entry content */ ?>
                        <div class="entry-content">
    <?php the_content( __( 'Continue reading <span class="meta-nav">&raquo;</span>', 'your-theme' )  ); ?>
    <?php wp_link_pages('before=<div class="page-link">' . __( 'Pages:', 'your-theme' ) . '&after=</div>') ?>
                        </div><!-- .entry-content -->
    
    <?php /* Microformatted category and tag links along with a comments link */ ?>
                        <div class="entry-utility">
                            <span class="cat-links"><span class="entry-utility-prep entry-utility-prep-cat-links"><?php _e( 'Posted in ', 'your-theme' ); ?></span><?php echo get_the_category_list(', '); ?></span>
                            <span class="meta-sep"> | </span>
                            <?php the_tags( '<span class="tag-links"><span class="entry-utility-prep entry-utility-prep-tag-links">' . __('Tagged ', 'your-theme' ) . '</span>', ", ", "</span>\n\t\t\t\t\t\t<span class=\"meta-sep\">|</span>\n" ) ?>
                            <span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'your-theme' ), __( '1 Comment', 'your-theme' ), __( '% Comments', 'your-theme' ) ) ?></span>
                            <?php edit_post_link( __( 'Edit', 'your-theme' ), "<span class=\"meta-sep\">|</span>\n\t\t\t\t\t\t<span class=\"edit-link\">", "</span>\n\t\t\t\t\t\n" ) ?>
                        </div><!-- #entry-utility -->
                    </div><!-- #post-<?php the_ID(); ?> -->
    
    <?php /* Close up the post div and then end the loop with endwhile */ ?>  
    
    <?php endwhile; ?>
  8. beholdadmin
    Member
    Posted 1 year ago #

    Thanks for the help, wpismypuppet. Just resolved the issue.

    UPDATE:

    There were a couple similar situations posted on this board so I made similar adjustments based off of those situations. Did no modifying to the PHP.

    I made a backup of my index.php file and saved it as index-backup. I copied my _blog.php template file and pasted the entire file in place of my original index.php file and continued to save the file as index.php. I set my reading settings for 'Posts page' to 'Blog' which was my original Blog template. Because of the redirect the blog page now displays correctly with all posts.

    Hope this can help others as well.

  9. wpismypuppet
    Member
    Posted 1 year ago #

    Glad you were able to solve the issue! You should mark this as "resolved" so other people know it's fixed. Thanks.

  10. beholdadmin
    Member
    Posted 1 year ago #

    Resolved. Thanks again.

Topic Closed

This topic has been closed to new replies.

About this Topic