• Resolved ilove@112

    (@bobbyng)


    Hi,

    I’ve used this plugin with WPML and I made a mistake when I translate the store data. I started to translate the store data at the end of all the record so the order of id is totally different. Then, I would like to ask you about if there is any way to overwrite the sorting by date??

    I’ve tried to use below coding and tried to $custom_sort[$key] = $row['date']; but it didn’t work.

     
    add_filter( 'wpsl_store_data', 'custom_result_sort' );
    
    function custom_result_sort( $store_meta ) {
        
        $custom_sort = array();
        
        foreach ( $store_meta as $key => $row ) {
            $custom_sort[$key] = $row['store'];
        }
    
        array_multisort( $custom_sort, SORT_ASC, SORT_REGULAR, $store_meta );
        
        return $store_meta;
    }
    
    
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Tijmen Smit

    (@tijmensmit)

    The publish date is by default not included in the returned search results. To make it work you will first have to include that value with the wpsl_store_meta filter.

    You can use the get_the_datefunction in combination with the store ID to get the post date, and then include that in the store meta under the date key.

    
    $store_meta['date'] = 'code to grab the location date';
    

    I didn’t test this, but you get the idea.

    Thread Starter ilove@112

    (@bobbyng)

    Ho, thank you for your help! It works now.

    • This reply was modified 6 years, 9 months ago by ilove@112.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How can I order the store list by date??’ is closed to new replies.