Using Ajax in the prev_posts_link and next_posts_link

I am using the add_filter() function in my functions.php file, to give my prev_posts_link and next_posts_link individual classes. The following code successfully loads the individual classes, prev_button and next_button.

add_filter('next_posts_link_attributes', 'posts_link_attributes_1');
add_filter('previous_posts_link_attributes', 'posts_link_attributes_2');

function posts_link_attributes_1() {
return 'class="prev_button" onclick="javascript:ajax_loadContent('box-right',' .      next_posts_link() . '");return false"';
}

function posts_link_attributes_2() {
return 'class="next_button" onclick="javascript:ajax_loadContent('box-right',' .      previous_posts_link() . '");return false"';
}

I am also using the onclick="javascript:ajax_loadContent('box-right',' . previous_posts_link() . '");return false code to load posts in my box-right DIV, using Ajax. Unfortunately, when I use . previous_posts_link() . in with my onclick attribute, it only gives me the .../posts.php instead of ...posts.php?paged=2

Read More

Any idea what I have done wrong?

Thanks.

Related posts