Show post type results based on custom filed date expiration

  • 2 years, 2 months ago #30677

    Hello Team,
    We have a post type with an custom field of date picker, we would like show the results based on the date in desc order like new to old. Is there any settings we can modify/add in order to achieve the requirement

    wpsolr
    Keymaster
    2 years, 2 months ago #30678

    Yes, any custom field indexed in screen 2.2 can be used as default sort in screen 2.5

    2 years, 2 months ago #30679

    you are right, but it should apply only for one custom post type not for all post types in search. Can we done for only particular post type using index boost factor?

    wpsolr
    Keymaster
    2 years, 2 months ago #30680

    Boost is reordering from matching between the field content and keywords, not base on field content alone.

    You could use Advanced decay scoring, which requires Elasticsearch.

    Or set your own custom field as default sort on your post type archive (does not work on general search with mixed post type results), with code:

    add_filter( WPSOLR_Events::WPSOLR_FILTER_DEFAULT_SORT, 'my_filter_default_sort', 10, 2 );
    public function my_filter_default_sort( $default_sort, $wpsolr_query ) {
     if ( /* condition here to detect the post type archive */ ) {
    	return 'my_custom_field' . '_str' . '_desc';
     } 
     return default_sort;
    }
    • This reply was modified 2 years, 2 months ago by wpsolr.
    2 years, 2 months ago #30757

    where can we download the Advanced Scoring add-on?

    wpsolr
    Keymaster
    2 years, 2 months ago #30758

    Please follow the documentation: Advanced decay scoring

    2 years, 2 months ago #30761

    yes, Got it. Thank you

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

You must be logged in to reply to this topic.