• Resolved kaushalacharya

    (@kaushalacharya)


    Hi All,

    Here is my page https://www.godfathercoupons.com/index.php?search-class
    It gives output with following query :-

    SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.post_type = ‘post’ AND (wp_posts.post_status = ‘publish’) LIMIT 0, 10

    I just want to add order by in that query order by post_title desc
    How can I do that? because I do not know from where the query is getting generated.

    I used the following :-
    global $query_string;
    query_posts( $query_string . ‘orderby=post_title&order=ASC’ );

    & then if I am echoing a query like echo $wp_query->request;
    It is giving the same query as previous no change.

    Thanks
    Kaushal

    [mod note: don’t bump your topic, it is not permitted on these forums]

Viewing 3 replies - 61 through 63 (of 63 total)
  • pravesht0

    (@pravesht0)

    my query is not returning any result what’s wrong with it

    SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) WHERE 1=1 AND wp_posts.post_type = ‘artwork’ AND (wp_posts.post_status = ‘publish’ OR wp_posts.post_status = ‘private’) AND ( (wp_postmeta.meta_key = ‘_my_artist_name’ AND CAST(wp_postmeta.meta_value AS CHAR) = ‘hilary_tjapaltjarri’) ) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 4

    pravesht0

    (@pravesht0)

    SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) WHERE 1=1 AND wp_posts.post_type = 'artwork' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') AND ( (wp_postmeta.meta_key = '_my_artist_name' AND CAST(wp_postmeta.meta_value AS CHAR) = 'hilary_tjapaltjarri') ) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 4

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

Viewing 3 replies - 61 through 63 (of 63 total)
  • The topic ‘Add where clause in query run time’ is closed to new replies.