Blog page not showing posts
-
Hello!
Working on a custom WordPress theme and having issues getting the Blog page to load. It was loading fine originally, but at some point in the last few days it won’t load correctly any more.
When selecting the “Blog” page via Settings>Reading>Front page display, the <article> tag returns blank (no page title, or posts displayed).
When I remove the “Blog” page from the Settings>Reading>Front page display, and set the template to either “Default template” or “Blog”, the <article> tag shows up but only displays the page title “Blog”.
When copying the files from the default themes (twentyfifteen) over to the custom theme, I still receive the same errors.
However, when testing the page running on twentyfifteen theme, the Blog page displays normally.
I’ve disabled all plugins one by one to see if it would fix things, but no change.
The category.php and archive file loads the posts normally.
I’m thinking the issue resides inside the content.php file. But can’t find the issue here.
Here’s the code I have inside the content.php file:
<?php /** * The default template for displaying content * * Used for both single and index/archive/search. * * @package WordPress * @subpackage Business * @since Business 1.0 */ ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <?php // Post thumbnail. business_post_thumbnail(); ?> <header class="entry-header"> <?php if ( is_single() ) : the_title( '<h1 class="entry-title">', '</h1>' ); else : the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); endif; ?> </header><!-- .entry-header --> <div class="entry-content"> <?php /* translators: %s: Name of current post */ the_content( sprintf( __( 'Continue reading %s', 'business' ), the_title( '<span class="screen-reader-text">', '</span>', false ) ) ); wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'business' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>', 'pagelink' => '<span class="screen-reader-text">' . __( 'Page', 'business' ) . ' </span>%', 'separator' => '<span class="screen-reader-text">, </span>', ) ); ?> </div><!-- .entry-content --> <?php // Author bio. if ( is_single() && get_the_author_meta( 'description' ) ) : get_template_part( 'author-bio' ); endif; ?> <footer class="entry-footer"> <?php business_entry_meta(); ?> <?php edit_post_link( __( 'Edit', 'business' ), '<span class="edit-link">', '</span>' ); ?> </footer><!-- .entry-footer --> </article><!-- #post-## -->
—
and this is the index.php and blog.php file:
<?php /** * Template name: Blog * * This is the most generic template file in a WordPress theme * and one of the two required files for a theme (the other being style.css). * It is used to display a page when nothing more specific matches a query. * e.g., it puts together the home page when no home.php file exists. * * Learn more: {@link https://codex.www.ads-software.com/Template_Hierarchy} * * @package WordPress * @subpackage Business * @since Business 1.0 */ get_header(); ?> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <?php if ( have_posts() ) : ?> <?php if ( is_home() && ! is_front_page() ) : ?> <header> <h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1> </header> <?php endif; ?> <?php // Start the loop. while ( have_posts() ) : the_post(); /* * Include the Post-Format-specific template for the content. * If you want to override this in a child theme, then include a file * called content-___.php (where ___ is the Post Format name) and that will be used instead. */ get_template_part( 'content', get_post_format() ); // End the loop. endwhile; // Previous/next page navigation. the_posts_pagination( array( 'prev_text' => __( 'Previous page', 'business' ), 'next_text' => __( 'Next page', 'business' ), 'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'business' ) . ' </span>', ) ); // If no content, include the "No posts found" template. else : get_template_part( 'content', 'none' ); endif; ?> </main><!-- .site-main --> </div><!-- .content-area --> <?php get_footer(); ?>
- The topic ‘Blog page not showing posts’ is closed to new replies.