0

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...

  • 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 – gmazzap 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.