mirror of
https://gh.llkk.cc/https://github.com/Tetrakern/fictioneer-email-notifications.git
synced 2025-10-03 18:11:01 +08:00
Query stories by default and order search by relevance
This commit is contained in:
parent
f8a6236daf
commit
20a7a4cffe
3 changed files with 17 additions and 20 deletions
28
ajax.php
28
ajax.php
|
@ -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
|
||||
|
|
2
js/fcnen-frontend.min.js
vendored
2
js/fcnen-frontend.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -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',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue