douzhong4222 2016-05-08 09:13
浏览 15
已采纳

将div添加到导航 - Wordpress

In the functions.php of my Wordpress site creates the back/next buttons

<?php if ( is_single() ) : // navigation links for single posts ?>

    <?php next_post_link( '<div class="nav-next">%link</div>', '<span class="fa fa-chevron-right"></span>' . _x( '', 'Previous post link', 'bnNav' ) ); ?>
    <?php previous_post_link( '<div class="nav-previous">%link</div>', _x( '', 'Next post link', 'bnNav' ). '<span class="fa fa-chevron-left"></span>'); ?>

...

which outputs

<nav id="nav-below" class="post-navigation" role="navigation">
  <div class="nav-next">
      <a rel="next" href="http://localhost/wordpress/?p=369">
  </div>

  <div class="nav-previous">
     <a rel="prev" href="http://localhost/wordpress/?p=104">
  </div>
</nav>

I want to put another div inside each div inside the .nav but not sure how to add it to the code in my functions.php

I WANT the output to be

<nav id="nav-below" class="post-navigation" role="navigation">
  <div class="nav-next">
      <div id="arrow-right"></div>
      <a rel="next" href="http://localhost/wordpress/?p=369">
  </div>

  <div class="nav-previous">
     <div id="arrow-left"></div>
     <a rel="prev" href="http://localhost/wordpress/?p=104">
  </div>
</nav>
  • 写回答

1条回答 默认 最新

  • douwei7501 2016-05-08 09:17
    关注

    Try to use the following code:

    <?php if ( is_single() ) : // navigation links for single posts ?>
    
        <?php next_post_link( '<div class="nav-next"><div id="arrow-right"></div>%link</div>', '<span class="fa fa-chevron-right"></span>' . _x( '', 'Previous post link', 'bnNav' ) ); ?>
        <?php previous_post_link( '<div class="nav-previous"><div id="arrow-left"></div>%link</div>', _x( '', 'Next post link', 'bnNav' ). '<span class="fa fa-chevron-left"></span>'); ?>
    

    Simply add the new <div> before the %link.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 matlab有关常微分方程的问题求解决
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考