Query stories by default and order search by relevance

This commit is contained in:
Tetrakern 2024-06-29 20:45:56 +02:00
parent f8a6236daf
commit 20a7a4cffe
3 changed files with 17 additions and 20 deletions

View file

@ -235,20 +235,24 @@ function fictioneer_ajax_fcnen_search_content() {

// Query stories
if ( $filter === 'story' && get_option( 'fcnen_flag_subscribe_to_stories' ) ) {
$stories = new WP_Query(
array(
'post_type' => 'fcn_story',
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'desc',
'posts_per_page' => 10,
'paged' => $page,
's' => $search,
'update_post_meta_cache' => true, // We might need that
'update_post_term_cache' => false // Improve performance
)
$search_args = array(
'post_type' => 'fcn_story',
'post_status' => 'publish',
'orderby' => 'relevance modified',
'order' => 'desc',
'posts_per_page' => 25,
'paged' => $page,
's' => $search,
'update_post_meta_cache' => true, // We might need that
'update_post_term_cache' => false // Improve performance
);

if ( ! $search ) {
$search_args['orderby'] = 'modified';
}

$stories = new WP_Query( $search_args );

// Build and add items
foreach ( $stories->posts as $item ) {
// Add to output

File diff suppressed because one or more lines are too long

View file

@ -389,13 +389,6 @@ function fcnen_search(page = 1, append = false) {
search.value = search.value.slice(0, 200);
}

// Search empty?
if (search.value == '' && filter?.value == 'story') {
sourceList.innerHTML = '';
sourceList.appendChild(fcnen_modal.querySelector('[data-target="fcnen-no-matches-item"]').content.cloneNode(true));
return;
}

// Prepare payload
const payload = {
'action': 'fictioneer_ajax_fcnen_search_content',