gpt4 book ai didi

wordpress - 正在处理帖子而不是在页面上显示分页

转载 作者:行者123 更新时间:2023-12-04 17:22:06 25 4
gpt4 key购买 nike

我从头开始创建了一个主题,并在帖子页面上使用分页,它在 single.php 上工作。

<?php get_header(); ?>

<?php

while(have_posts()) {
the_post();
?>
<div class="mainConent">
<div class="leftSidebar">
<div class="sidebarTitleWrapper">
<?php dynamic_sidebar('left_sidebar') ?>
</div>
</div>
<div class="recentBlogsWrapper">
<div class="blogWrapper">
<h2><?php the_title(); ?></h2>
<p><?php the_time('F j, Y') ?></p>
<?php if(has_post_thumbnail()) { ?>
<div class="card-image">
<img class="page-image" src="<?php echo get_the_post_thumbnail_url(get_the_ID()); ?>" alt="Card Image">
</div>
<?php } ?>
<div class="card-description">
<?php the_content(); ?>
<?php wp_link_pages(); ?>
<?php comments_template(); ?>
<?php } ?>
<div class="backarrowwrap">
<a class="backhomelink" href="<?php echo site_url(); ?>" <?php if(is_front_page()) echo 'class="active"' ?>>
<img class="backarrow" src="<?php echo get_template_directory_uri(); ?>/img/backarrow.png" alt="back arrow" />
Go Back Home
</a>
</div>
</div>
</div>
</div>
<div class="rightSidebar" id="sidebar">
<div class="sidebarTitleWrapper">
<?php dynamic_sidebar('right_sidebar') ?>
</div>
</div>

我把它放在 the_content() 的正下方;它的工作方式与我想要的完全一样。但是,它不适用于 page.php,即使它位于页面上的同一位置。

<?php get_header();

while(have_posts()) {
the_post();
?>
<div class="pageWrapper">
<h2><?php the_title(); ?></h2>
<?php if(has_post_thumbnail()) { ?>
<div class="card-image">
<img class="page-image" src="<?php echo get_the_post_thumbnail_url(get_the_ID()); ?>" alt="Card Image">
</div>
<?php } ?>
<div class="card-description">
<?php the_content(); ?>
<?php wp_link_pages(); ?>
<?php } ?>
</div>
</div>

<?php get_footer(); ?>

我已经包含了

<!–-nextpage-–>

在我的一个页面中编写代码,就像我在博客中所做的那样,但它不会在段落之间分页。

我做错了什么?

最佳答案

您至少需要 one <!--nextpage--> ,如果页面(或帖子)的内容至少有一个 <!--nextpage-->标记(并且此代码在 The Loop 中),这会打印链接页码 (“Pages: 1 2 3 4 and so on...”),当前页码上没有链接,并且通过默认在

标签内:.

关于wordpress - <?php wp_link_pages(); ?> 正在处理帖子而不是在页面上显示分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60273553/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com