Loop is breaking my theme. How can I fix?

When my theme tries to load home.php, archive.php or any page that uses the loop, the page will stop loading exactly at

When my theme tries to load home.php, archive.php or any page that uses the loop, the page will stop loading exactly at the point the loop should begin, even the wpadmin bar won't load.

If I navigate to a category page that has no content to show (as no posts are labelled as that category) the page will load perfectly well with the wpadmin bar, and show a 404 where the content would be. (Expected behavior)

Anyone know why this would happen?

Here is my loop:

<div id="primary" class="content-area">

 <main id="main" class="site-main" role="main">

  <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

            <?php get_template_part( 'template-parts/content', 'posts'); ?>

        <?php endwhile; else : ?>

            <?php get_template_part( 'template-parts/content', 'none' ); ?>

        <?php endif; ?>

    <div class="pagination">

      <?php echo paginate_links( array(
        'prev_text' => 'Back',
        'next_text' => 'Next',
        'end_size' => '0',
        'mid_size' => '1'
      ) ); ?>

    </div>

</div><!--primary-->

The main tag is closed in the footer.

Here is my content-posts.php code (you might not need to look at this but posting here just in case):

<article id="post-<?php the_id(); ?>" <?php  post_class(); ?>>

<header class="entry-header">

    <div class="article-excerpt">

        <!-- The following links the thumbnail image to the atricle, if there is a thumbnail -->
        <?php   if ( has_post_thumbnail() ) : ?>
            <a href="<?php the_permalink(); ?>"
            title="<?php the_title_attribute(); ?>">
            <img src="<?php the_post_thumbnail_url(); ?>"/>
            </a>
        <?php endif; ?>

        <div class="byline"> <?php get_template_part( 'template-parts/byline' ); ?></div>
        <?php   the_title( '<h2><a href="' . esc_url( get_permalink() ) . '">', '</a></h2>' ); ?>
        <div class="excerpt-date"><?php the_date( '','// ','', ) ?></div>
    </div>

    <hr class="excerpt-hrtop">

</header>

<div class="entry-content">

    <a href="<?php the_permalink() ?>">
        <?php the_content( '<div class="excerpt-readmore">READ MORE</div>' ); ?>
    </a>

</div>

<hr class="excerpt-hrbottom">

I have tried using query_posts before the loop as was advised in answers to other questions and that didn't work.

I use DesktopServer to work offline and the website works great.

Any help is much appreciated.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745361956a4624400.html

相关推荐

  • Loop is breaking my theme. How can I fix?

    When my theme tries to load home.php, archive.php or any page that uses the loop, the page will stop loading exactly at

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信