Get post content outside the loop
-
i want to get the post content via AJAX when the user click a post.
in my theme folder i created a getpost.php:<?php $id = (int)$_GET['post_id']; $post = get_post($id); echo $post->post_content; ?>
Then i call it like:
$.ajax({ url:themepath+'/getpost.php?post_id='+id, success:function(data){ alert(data) } });
i also tryied
query_posts('p='.$id);
,get_post_field( 'content', $id );
but they all return a error like
Fatal error: Call to undefined function get_post()
- The topic ‘Get post content outside the loop’ is closed to new replies.