Domanda

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;
È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top