Order by package id

This topic contains 3 replies, has 3 voices, and was last updated by  Stiofan O’Connor 8 years, 8 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #53118

    Good Faith Hope
    Buyer
    Post count: 66

    Hi,
    I found some code in a previous post that could be used to order listings by package ID. By default I would like it ordered by Featured, Basic, and Free for each custom post type. I tried the following code, changing only the id numbers, but I can’t get it to work. Am I missing something else?

    
    
    add_filter('geodir_posts_order_by_sort', 'geodir_posts_order_by_sort_my_change',10,3);
    
    function geodir_posts_order_by_sort_my_change($orderby, $sort_by, $table){
    
    if($orderby==' '){
    //$orderby = " $table.package_id asc, ";// simply order by package id lowest to greatest
    $orderby = " FIELD($table.package_id,1,5,4,3), "; // order by specific package id's
    }
    
    return $orderby;
    }

    Here are the package levels I have:

    1 Free gd_place
    2 Free gd_services
    3 Free gd_sitesandresources
    4 Free gd_books
    5 Basic gd_place
    6 Basic gd_services
    7 Basic gd_sitesandresources
    9 Featured gd_place
    10 Featured gd_services
    11 Featured gd_sitesandresources
    12 Free gd_event
    13 Basic gd_event
    14 Featured gd_event

    Thanks for your help, as always!

    #53168

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    The only solution I see is to recreate your packages ID so to have the correct ID and be sorting as you want them.

    I don’t think you can pass a manual order.

    However I’m sorry, but we don’t provide support for customizations.

    Thank you

    #53222

    Good Faith Hope
    Buyer
    Post count: 66

    Sorry, Paolo. I don’t know what you mean by “sorting as you want them” because even after changing the IDs from 1 to 15 from Featured to Free, the listings don’t appear in that order. I changed the code to:

    
    
    $orderby = " $table.package_id asc, ";// simply order by package id lowest to greatest
    //$orderby = " FIELD($table.package_id,1,5,4,3), "; // order by specific package id's

    I was using a previous directory theme before I purchased Geodirectory. In the previous theme, members were able to purchase packages in order to appear higher in search results. That’s why I desperately need this, because users aren’t getting what they paid for. Not Geodirectory’s fault, but I’m just wondering why adding this code to functions isn’t working for me.

    If this is not something you can help me with, I’d appreciate some help from any of the other members in the forum.

    Please, anyone??

    #53277

    Stiofan O’Connor
    Site Admin
    Post count: 22956

    Hi Dee,

    Firstly before i did into it (if still needed) You do know if you mark listings featured that they will appear first under the normal sort order in listings? You can assign a package to be featured and make it more expensive etc..

    If that is not enough let me know and i’ll have a look at the code.

    Thanks,

    Stiofan

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

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket