refactor(resource): drop aksrt_resource CPT residue, post+meta only
This commit is contained in:
1 parent
24c135aeec
commit
1af0e9b753
22 files changed
+362
-986
No files matched your search
@@ -2,8 +2,7 @@
|
||||
/**
|
||||
* Resource Related
|
||||
*
|
||||
* 单篇资源页底部的「相关资源」区块。
|
||||
* 取同分类下其它资源(post + _aksrt_is_resource = 1,兼容旧 aksrt_resource CPT),按下载量倒序。
|
||||
* 单篇资源页底部「相关资源」:同分类其它资源帖(post + _aksrt_is_resource)。
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
@@ -11,13 +10,13 @@
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$current_id = get_the_ID();
|
||||
$cat_ids = wp_get_post_categories($current_id, ['fields' => 'ids']);
|
||||
if (empty($cat_ids)) return;
|
||||
|
||||
$post_types = function_exists('aksrt_resource_post_types') ? aksrt_resource_post_types() : ['post'];
|
||||
$cat_ids = wp_get_post_categories($current_id, ['fields' => 'ids']);
|
||||
if (empty($cat_ids)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$args = [
|
||||
'post_type' => $post_types,
|
||||
'post_type' => 'post',
|
||||
'posts_per_page' => 6,
|
||||
'post__not_in' => [$current_id],
|
||||
'category__in' => array_map('intval', $cat_ids),
|
||||
@@ -25,17 +24,12 @@ $args = [
|
||||
'orderby' => 'meta_value_num',
|
||||
'order' => 'DESC',
|
||||
'no_found_rows' => true,
|
||||
'meta_query' => [
|
||||
function_exists('aksrt_resource_meta_query')
|
||||
? aksrt_resource_meta_query()
|
||||
: ['key' => '_aksrt_is_resource', 'value' => '1', 'compare' => '='],
|
||||
],
|
||||
];
|
||||
if (!post_type_exists('aksrt_resource')) {
|
||||
$args['meta_query'] = [
|
||||
'relation' => 'AND',
|
||||
[
|
||||
'key' => '_aksrt_is_resource',
|
||||
'value' => '1',
|
||||
'compare' => '=',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
$query = new WP_Query($args);
|
||||
|
||||
@@ -49,10 +43,9 @@ if (!$query->have_posts()) {
|
||||
<header class="resource-related__header">
|
||||
<h2 class="resource-related__title"><?php esc_html_e('相关资源', 'aksrt'); ?></h2>
|
||||
</header>
|
||||
|
||||
<div class="post-grid post-grid--grid-cms resource-related__grid">
|
||||
<div class="resource-related__grid post-grid post-grid--card">
|
||||
<?php
|
||||
set_query_var('aksrt_post_card_layout', 'grid-cms');
|
||||
set_query_var('aksrt_post_card_layout', 'card');
|
||||
while ($query->have_posts()) {
|
||||
$query->the_post();
|
||||
get_template_part('templates/parts/content', 'post-card');
|
||||
|
||||
Reference in new issue
Block a user