• Resolved phillip415

    (@phillip415)


    I already put this code inside my functions.php and changed stores to city which sorty my stores alphabetically by city, but I want 2 specific stores to be listed first. How to do this?

    This is a basic example how it would work, but I don’t know how to use this inside my custom_result_sort function

    $stores = array("A", "B", "C", "D");
    
    usort($stores, function($a, $b) {
    
    if ($b == "C") {
      return 1;
    }
    
    });
    • This topic was modified 6 years, 6 months ago by phillip415.
    • This topic was modified 6 years, 6 months ago by phillip415.
Viewing 1 replies (of 1 total)
  • Plugin Author Tijmen Smit

    (@tijmensmit)

    You can use the wpsl_store_data filter to both order by city, and order by featured store.

    The two stores that are set as featured store will have the ‘featured_dealer’ key set, so you can remove them from the results and place them in a new array, sort by city and then merge both arrays so that the featured stores show up first.

Viewing 1 replies (of 1 total)
  • The topic ‘How to list two specific stores at first and sort the rest alphabetically?’ is closed to new replies.