php - 上一篇文章 ID 未使用此代码显示
问题描述
尝试使用此代码获取上一个帖子 ID,但它只显示当前帖子 ID
$prev_post = get_adjacent_post(false, '', true);
if(!empty($prev_post)) {
$xx = get_the_ID($prev_post->ID);
$yy = get_the_ID($post->ID);
echo $xx;
echo $yy;
解决方案
请尝试一下:
$prev_post = get_adjacent_post(false, '', true);
echo $prev_post->ID;
推荐阅读
- azure - azure cosmosDB 3.6 对索引超过最大数量的字段排序操作的问题
- python-2.7 - CERTIFICATE_VERIFY_FAILED 通过 spark-submit 与成功手动执行 python 代码
- regex - 一种正则表达式模式,但不是另一种
- gstreamer - 为什么 gStreamer 从 waylandsink 抛出错误?
- android - Firebase - 删除 Firebase 上的项目会影响 Google Play?
- ruby - 如何使用 CURL 从终端发送的自定义标头将数据保存在我的文件中
- wpf - Devexpress:如何在数据模板中访问控制
- mysql - 根据一列 MariaDB 从重复项中获取第一行
- java - 如何在不重复的情况下随机选择泛型类型
- reactjs - .map 不是函数。通过对象数组映射。(反应钩子)