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;
}
and
$.get(
ajaxYall.ajaxurl,
{
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.
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.