wordpress - 在 single.php 中自动加载帖子
问题描述
我正在尝试在 single.php 中自动加载我的所有帖子我尝试了几个插件但都不起作用可能是什么问题我也尝试了几个导航菜单但我找不到问题是我有同样的问题在这个问题中 https://wordpress.stackexchange.com/questions/102604/enable-infinite-scroll-on-single-php 这是我的单页
<?php
/**
* The template for displaying all single posts
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
*
* @package NewsCard
*/
get_header();
newscard_layout_primary(); ?>
<main id="main" class="site-main">
<?php
while ( have_posts() ) :
the_post();
get_template_part( 'template-parts/content', get_post_type() );
the_post_navigation();
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :
comments_template();
endif;
endwhile; // End of the loop.
?>
</main><!-- #main -->
</div><!-- #primary -->
<?php
do_action('newscard_sidebar');
if ( $newscard_settings['newscard_footer_featured_posts_hide'] === 0 ) {
$footer_newscard_cat = absint($newscard_settings['newscard_footer_featured_post_categories']);
$footer_post_type = array(
'posts_per_page' => 4,
'post__not_in' => get_option('sticky_posts'),
'post_type' => array(
'post'
),
);
if ( $newscard_settings['newscard_footer_featured_latest_post'] == 'category' ) {
$footer_post_type['category__in'] = $footer_newscard_cat;
}
$footer_newscard_get_featured_post = new WP_Query($footer_post_type); ?>
<div class="container">
<section class="featured-stories">
<h2 class="stories-title"><?php echo esc_html($newscard_settings['newscard_footer_featured_posts_title']); ?></h2>
<div class="row gutter-parent-14">
<?php while ($footer_newscard_get_featured_post->have_posts()) {
$footer_newscard_get_featured_post->the_post(); ?>
<div class="col-sm-6 col-lg-3">
<div class="post-boxed">
<?php if ( has_post_thumbnail() ) { ?>
<div class="post-img-wrap">
<div class="featured-post-img">
<a href="<?php the_permalink(); ?>" class="post-img" style="background-image: url('<?php echo esc_url(get_the_post_thumbnail_url(get_the_ID(),'full')); ?>');"></a>
</div>
<div class="entry-meta category-meta">
<div class="cat-links"><?php the_category(' '); ?></div>
</div><!-- .entry-meta -->
</div><!-- .post-img-wrap -->
<?php } ?>
<div class="post-content">
<?php if ( !has_post_thumbnail() ) { ?>
<div class="entry-meta category-meta">
<div class="cat-links"><?php the_category(' '); ?></div>
</div><!-- .entry-meta -->
<?php } ?>
<?php the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '">', '</a></h3>' ); ?>
<?php if ( 'post' === get_post_type() ) { ?>
<div class="entry-meta">
<?php newscard_posted_on(); ?>
</div>
<?php } ?>
</div><!-- .post-content -->
</div><!-- .post-boxed -->
</div><!-- .col-sm-6 .col-lg-3 -->
<?php }
// Reset Post Data
wp_reset_postdata(); ?>
</div><!-- .row -->
</section><!-- .featured-stories -->
</div><!-- .container -->
<?php }
get_footer();
?>