I'm using WordPress (WP) as the backend for an app that delivers content on a map.

I've been trying for a couple of days to get my head around AJAx in WP and have found a good tutorial I'm trying to follow.

I've adapted it for use in the theme, however how do I get it to 'GET' the_content?

The parts that are relevant:

function the_content( $content ) {

global $post;

if( is_single() && 'post' == $post->post_type ) { //I'll want post from a specific category, not just single posts.

$content .= '<button class="ajax-yall" data-postid="'. $post->ID .'">'.     __('Click me!', 'ajax-yall') .'</button>'; //here I want it to get the post content of posts in a particular category
return $content;


            action  : ajaxYall.action,
            nonce   : ajaxYall.nonce,
            postID  : $el.attr('data-postid')

I've had various attempts at this, but my knowledge on the subject isn't sufficient.

  • the_content() is a WordPress core function. If you try to create a function called the_content() in the WordPress environment, it should throw a fatal error.
    – Pat J
    Commented Feb 5, 2014 at 0:47

1 Answer 1


I'm sorry but I think you have not read a good tutorial. If you are new to Wordpress AJAX, I recomend you reading AJAX in WP Codex and examples plus all the examples you can find in this site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.