WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a custom page, in that page i am using a custom select query for my search functionality.

The problem is pagination not working. I used $on_page= get_query_var('paged'); for pagination. When I echo $on_page, it always return 0 as the result. I am using a custom theme (soundwaves) for my site.

This is my query:

$resultsTotal = $wpdb->get_results(
    "SELECT p.post_title,p.ID,pm.meta_value 
        FROM wp_posts p 
        join wp_postmeta pm ON p.ID=pm.post_id 
        WHERE  pm.meta_value 
                LIKE '%$track%' AND (p.post_type='post' AND p.post_status='publish')  
        GROUP BY p.ID"
share|improve this question
Please take a look at like_escape() and meta-query. – kaiser Apr 26 '13 at 11:35
Please post all of the relevant code. As is, I can't see why you need a custom SQL query at all. – s_ha_dum Apr 26 '13 at 13:09

Your Answer


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

Browse other questions tagged or ask your own question.