drby30217 2012-04-23 15:27
浏览 10
已采纳

检索最新页面修订版的Wordpress问题

I have some code that retrieves a page from the backend of Wordpress. I use the post_id to retrieve it. The issue is that when I modify the page content, the changes have a new post id. Is there a good way to retrieve the latest revision of a page. The title will never change.

Also I am accessing these pages outside of Wordpress.

                $pagelisting = $_GET['pagelisting'];
                require( '../blog/wp-load.php' );
                define('WP_USE_THEMES', false);
                query_posts('showposts=1');

                $post_id = 195;
                $queried_post = get_post($post_id);
                $title = $queried_post->post_title;

                $content = $queried_post->post_content;
                $content = apply_filters('the_content', $content);

                echo $content;
  • 写回答

1条回答 默认 最新

  • doushu5451 2012-04-23 17:50
    关注

    The post with the original post id is the current post, you will see that it has post_status = 'publish', the revisions have a post_parent that matches the original post id and a post status of 'inherit'.

    I hope this helps. /peter

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

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法