简体   繁体   中英

call wordpress post content on another external php page

public |-- index.php (external) |-- post-viewer.php (external) |-- /WP (wp installation)

I'm trying to call postings from wordpress installation from external page. I managed to display post title, excerpts, thumbnail and post content from the index page (by following tutorial : http://codex.wordpress.org/Integrating_WordPress_with_Your_Website ).

When I clicked on the post title on index.php my browser get redirected to Wordpress site (which I want to be hidden from public).

How do you make the post content appears on post-viewer.php instead ?

Thanks

Load the WordPress core functions and load trough the get_post option

<?php

   require_once("wp-load.php");

   $post = get_post( 12 ); // your post id

   echo $post->post_content;

?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM