There are a lot of similar questions asked here, but none of the suggestions seems to work for me.
I have the following code on my home page:
get_template_part( 'category-clients' );
And category-clients.php looks like this:
<div id="content">
<?php
global $paged;
global $wp_query;
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query('cat=251&posts_per_page=3'.'&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post();
?>
<?php the_title(); ?>
<?php endwhile; ?>
<div id="pagination">
<?php next_posts_link('« Older Entries') ?>
<?php previous_posts_link('Newer Entries »') ?>
</div>
<?php
$wp_query = null;
$wp_query = $temp;
?>
</div><!-- #content -->
Also... below this code, on category-clients.php, I have a jQuery script for AJAX loading of the different pages:
<script>
jQuery(document).ready(function(){
// AJAX pagination
jQuery(function(jQuery) {
jQuery('#content').on('click', '#pagination a', function(e){
e.preventDefault();
var link = jQuery(this).attr('href');
jQuery('#content').fadeOut(500, function(){
jQuery(this).load(link + ' #content', function() {
jQuery(this).fadeIn(500);
});
});
});
});
});
</script>
Now... if I go to $myurl/clients, the pagination works just fine, but on the homepage it doesn't. Any ideas? Thank you!