【问题标题】:<! --nextpage--> pagination is not working in Wordpress<! --nextpage--> 分页在 Wordpress 中不起作用
【发布时间】:2020-01-21 04:53:05
【问题描述】:

我正在尝试使帖子可以轻松地以自定义主题进行分页,但我做错了。我已经包括 wp_link_pages();在我认为需要的时候,但也许我把它放在错误的地方或者我错过了其他东西?

<?php get_header(); ?>

<?php  

while(have_posts()) {
    the_post();
    wp_link_pages();

?>
  <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 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>




<?php get_footer(); ?>

发生的另一件奇怪的事情是代码块在页面上显示代码,而不是像应有的那样隐藏它。

wordpress 编辑器

显示代码的我的博客文章页面

【问题讨论】:

  • 嗨,PHP 脚本在 wordpress 帖子编辑器中不起作用,为此您需要使用插件来说明为什么 php 脚本标签会显示在页面上
  • 我将它作为测试包含在链接中,我认为它不会那样工作。它也在代码中,但仍然不起作用。
  • 试试这个,wp_link_pages(array('before' => '', ' next_or_number' => 'next', 'previouspagelink' => __('Previous'), 'nextpagelink'=> __('Next') ) );
  • 无法让它工作。
  • 我刚刚发现 Gutenburg 编辑器是我的代码出现在页面上的原因,它将其显示为常规内容,而不是像它说的那样显示代码。我切换到经典视图,现在它工作了一半。页面的其余部分正在消失,但没有显示分页链接。

标签: wordpress pagination


【解决方案1】:

Gutenburg 阻止我将评论写成代码,即使是在代码框中也是如此。一旦我切换到经典视图,问题就消失了,因为我可以直接在 html 中写评论。

【讨论】:

    猜你喜欢
    • 2013-11-25
    • 2018-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-17
    • 1970-01-01
    相关资源
    最近更新 更多