Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何检索下一篇文章的url()和下一篇文章的标题()?_Php_Wordpress - Fatal编程技术网

Php 如何检索下一篇文章的url()和下一篇文章的标题()?

Php 如何检索下一篇文章的url()和下一篇文章的标题()?,php,wordpress,Php,Wordpress,这是我想与Wordpress的next_post_link()和previous_post_link()结合使用的HTML。您可以看到URL和标题由HTML标记包装,其中甚至有一个_cat_title()。由于这种复杂的HTML设置,我无法轻松使用next_post_link()和previous_post_link() 那么,我如何实现以下目标?我觉得我缺少了如下标记:next_post_url()和next_post_title() 我通过使用get\u nexting\u post()

这是我想与Wordpress的next_post_link()和previous_post_link()结合使用的HTML。您可以看到URL和标题由HTML标记包装,其中甚至有一个_cat_title()。由于这种复杂的HTML设置,我无法轻松使用next_post_link()和previous_post_link()

那么,我如何实现以下目标?我觉得我缺少了如下标记:next_post_url()和next_post_title()


我通过使用get\u nexting\u post()检索下一篇和上一篇文章来解决这个问题。然后使用get_permalink()和get_title()


  <p class="prev-next clearfix">
      <a href="http//loremipsum.com" class='prev <?php single_cat_title(); ?>'>
        <span class="header">Previous article</span>
        <span class="title">Lorem ipsum dolores amet title</span>
      </a>
      <a href="http://foorbar.com" class='next <?php the_filmcom_category(); ?>'>
        <span class="header">Next article</span>
        <span class="title">Foo bar title</span>
      </a>
  </p>
  <?php $nextpost = get_adjacent_post(true,'',false); ?>
  <?php $prevpost = get_adjacent_post(true,'',true); ?>

  <p class="prev-next">
      <a href="<?php echo get_permalink($prevpost); ?>" class='prev <?php the_filmcom_category(); ?>'>
        <span class="header">Previous article</span>
        <span class="title"><?php echo get_the_title($prevpost); ?></span>
      </a>
      <a href="<?php echo get_permalink($nextpost); ?>" class='next <?php the_filmcom_category(); ?>'>
        <span class="header">Next article</span>
        <span class="title"><?php echo get_the_title($nextpost); ?></span>
      </a>
  </p>