fix 更多栏目

This commit is contained in:
kate522 committed 2026-09-05 17:32:18 +08:00
1 parent 5b89fc200b
commit 05a6b6fc54
28 files changed
+440 -2295

No files matched your search

+7 -52
View File
@@ -43,60 +43,15 @@ if (!function_exists('aksrt_homepage_get_latest_query')) {
$query_args['category__not_in'] = $exclude_cat_ids;
}
$query = new WP_Query(aksrt_homepage_apply_sort_args($query_args));
return $query;
}
}
if (!function_exists('aksrt_homepage_get_tab_query')) {
/**
* Build a category-tab query.
*/
function aksrt_homepage_get_tab_query(int $term_id, string $orderby = 'date'): WP_Query {
static $queries = [];
$cache_key = $term_id . '_' . $orderby;
if (isset($queries[$cache_key]) && $queries[$cache_key] instanceof WP_Query) {
return $queries[$cache_key];
}
$term = get_term($term_id);
$taxonomy = ($term && !is_wp_error($term)) ? (string) $term->taxonomy : 'category';
if ($taxonomy !== 'category') {
$taxonomy = 'category';
}
$query_args = [
'post_type' => aksrt_homepage_get_post_types(),
'post_status' => 'publish',
'posts_per_page' => class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::homepage_tab_posts_per_page()
: 6,
'ignore_sticky_posts' => true,
'orderby' => 'date',
'order' => 'DESC',
'no_found_rows' => true,
'tax_query' => [
[
'taxonomy' => $taxonomy,
'field' => 'term_id',
'terms' => [$term_id],
],
],
];
$exclude_ids = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::home_exclude_post_ids()
: [];
if (!empty($exclude_ids)) {
$query_args['post__not_in'] = $exclude_ids;
}
$queries[$cache_key] = new WP_Query(
aksrt_homepage_apply_named_sort_args($query_args, $orderby)
// legacy zib_sift_posts_per_orde:排序菜单的 ?orderby= 优先于后台默认排序。
$request_sort = aksrt_homepage_get_request_sort();
$query = new WP_Query(
$request_sort !== ''
? aksrt_homepage_apply_named_sort_args($query_args, $request_sort)
: aksrt_homepage_apply_sort_args($query_args)
);
return $queries[$cache_key];
return $query;
}
}
if (!function_exists('aksrt_homepage_has_active_sidebars')) {