문제

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;
도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top