• 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 15 replies - 46 through 60 (of 63 total)
  • It is not using your custom results set this is the problem. You need to reset the Global post data after your custom query.

    I am running out of time I have to move on to paid work pretty soon.

    Thread Starter kaushalacharya

    (@kaushalacharya)

    Dear Sober,

    Now please check ?? you need to do color:#000; in pre tag

    Thanks
    Kaushal

    Its displaying the Global Post Data and not your custom query you need to reset the Global post data in order for it to use your custom results set.

    Thread Starter kaushalacharya

    (@kaushalacharya)

    Dear Sober,

    I got the thing it is not using our queryset hum hum
    Ok Sober now it looks like we are very close but yes I can understand your situation ??

    Now approx. 80 to 90% I will be able to handle. ?? so don’t worry Sober I will not ask you more questions ?? haha

    You helped me lot Sober ?? I am really thankful to you ??
    & yes please tell your hourly charge for hiring ??

    Please also let me know if I can rate your help as I asked yesterday also ??

    Really thanks sober for your all help ??

    Thanks
    Kaushal

    Kaushal

    No problem I enjoy helping its my job!

    You need to reset the Global Post Data, the below commands you can achieve this:

    wp_reset_postdata()
    wp_reset_query()

    S.

    @kaushalacharya,

    & yes please tell your hourly charge for hiring ??

    These forums are for only free, voluntary service to help out WordPress users and for seeking such free help. If you want to hire someone, please post your problem here: https://jobs.wordpress.net/post-a-job/

    Offering to pay and seeking hired services are against forum policies and rules.

    @krishna

    I did mention paid work in any sense its my hobby and passion to help people ??

    S.

    @sobermedia,
    Glad to note that! ??
    I just reminded kaushalacharya about the forum guidelines.

    Thread Starter kaushalacharya

    (@kaushalacharya)

    Dear Sober,

    I am very close ?? almost done but suddenly a jolt came ??
    Please see the below urls :-
    1) https://www.godfathercoupons.com/index.php?search-class&orderby=title&order=desc
    2) https://www.godfathercoupons.com/page/2/?search-class&orderby=title&order=desc

    First one will output okay but 2nd one is the url when we click on page number 2 but see that query. It is remaining same ??

    Any idea? What to do ??

    Thanks
    Kaushal

    Thread Starter kaushalacharya

    (@kaushalacharya)

    Dear Sober,

    I mean LIMIT 0,10 remains same even if we click on page number 2 ??

    Thanks
    Kaushal

    Thread Starter kaushalacharya

    (@kaushalacharya)

    Dear Sober,

    I am leaving for the day now as I am very tired & very late here ??
    If you post anything then tomorrow I will reply ??

    Bye ??

    Thanks
    Kaushal

    You might have to add some more code to your Custom Query.

    Something like:

    $paged = get_query_var(‘paged’) ? get_query_var(‘paged’) : 1;

    and add:

    ‘paged’ => $paged,

    to the query vars.

    Thread Starter kaushalacharya

    (@kaushalacharya)

    Dear Sober,

    You solved my problem ?? Issue has been resolved totally because of you only ??

    Thank you very very much for your great help ??
    I can say you are near to the master of wordpress ??

    I am really pleased with your approach & answering all the questions ??
    Is there any way I can rate your help? I would glad to do that ??

    Thanks Sober again ??

    Thanks
    Kaushal

    Kaushal

    No problems mate! Glad its fixed.

    I dont think you can rate me just glad to help. You can find me on the forums if you need any more help.

    Is there any way you can make this resolved?

    S.

    Thread Starter kaushalacharya

    (@kaushalacharya)

    Dear Sober,

    Thank you for all your help ??
    Yes I am making this issue as resolved ??

    Thanks
    Kaushal

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