Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using this to get the posts:

(...) if ( empty( $categories_defined) ) {

  $posts = get_posts($args);
} else {
  global $wpdb;
  $posts = $wpdb->get_results( $wpdb->prepare(
    "SELECT * FROM $wpdb->posts WHERE
    post_type = 'post' AND post_status = 'publish' AND
    post_title LIKE %s  ORDER BY post_title ASC LIMIT 50",
    $categories_defined . '%'
  ) );
} 

So I have already limited my posts, which is working fine, but I can't get the pagination. I tried using a plugin, shortcodes and the native pagination, but I can't find the problem. Can someone help me out with this? I'd like to have a next and previous pagination together with the navigation with numbers... One for above, one beneath the posts...

share|improve this question
1  
Where you put this code? In a page or in a singular post or in an archive template? Tip: for the else you can use the s argument for get_posts instad writng a custom SQL –  G. M. Aug 4 '13 at 9:30
    
In a page that I am using. Can you provide an example of what you mean with s? –  user1627363 Aug 4 '13 at 9:45
    
Please take a look at like_prepare() for your query. –  kaiser Aug 4 '13 at 11:08
    
Don't get it. What does it? There is not much documentation out there? –  user1627363 Aug 4 '13 at 11:19
    
Why are you not just using get_posts() for this? –  Pippin Aug 4 '13 at 17:16
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.