Forum: F.A.Q

This forum is closed for new topics. However, you can still search for a solution in the old topics. For technical support and general questions related to GEO my WP plugin and its core add-ons please use the support forum.

order results by custom field

Home Forums F.A.Q order results by custom field

This topic contains 5 replies, has 3 voices, and was last updated by  Eyal Fitoussi 4 weeks, 1 day ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #33877

    chunkymac
    Participant

    Hi,

    I have a custom results page which displays a few custom fields. One of these shows a ‘level’ that the post is at.

    I need edit the results.php template so that the results are ordered by this field – For example if the field name is ‘wpcf_status’ with possible values 1,2,3 or 4 how can I order the results so any with the value ‘1’ are displayed higher than those with value ‘2’?

    Many thanks

    Chris

    #33880

    Eyal Fitoussi
    Keymaster

    Hi Chris,
    You can use the filter gmw_pt_location_query_clauses which fires just before the search query to change the orderby clause. You can test the code below by changing the meta_key “test” to the meta key you want to use and add the code to your functions.php file.

    let me know if it helps.

    Thank you

    #33879

    chunkymac
    Participant

    That seems to work – many thanks indeed.

    #33878

    Eyal Fitoussi
    Keymaster

    You are very welcome.

    #59365

    kbleck
    Participant

    Hi there! This function doesn’t seem to work anymore…

    Can someone tell me if I’m doing something wrong??

    #59387

    Eyal Fitoussi
    Keymaster

    Hello @kbleck,

    What exactly are you trying to accomplish?

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.