最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Loop is breaking my theme. How can I fix?

programmeradmin1浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论