Hidden posts now have a "hidden" card

The meta query just was too expensive.
This commit is contained in:
Tetrakern 2023-08-05 21:45:08 +02:00
parent 97df64c774
commit b88f4972f7
8 changed files with 49 additions and 32 deletions

View File

@ -10,8 +10,8 @@
* @subpackage Fictioneer
* @since 3.0
*
* @internal ('fictioneer_filter_and_search_id') ACF field. You can use this ID for plugins.
* @internal ('fictioneer_short_name') ACF field. Meant for an abbreviated page name.
* @internal ('fictioneer_filter_and_search_id') ACF field. You can use this ID for plugins.
* @internal ('fictioneer_short_name') ACF field. Meant for an abbreviated page name.
*/
?>
@ -33,18 +33,7 @@ $query_args = array (
'orderby' => $orderby,
'order' => $order,
'paged' => $page,
'posts_per_page' => get_option( 'posts_per_page', 8 ),
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'fictioneer_chapter_hidden',
'value' => '0'
),
array(
'key' => 'fictioneer_chapter_hidden',
'compare' => 'NOT EXISTS'
)
)
'posts_per_page' => get_option( 'posts_per_page', 8 )
);
// Append date query (if any)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -42,7 +42,12 @@ if ( ! function_exists( 'fictioneer_chapters_list' ) ) {
while ( $args['chapters']->have_posts() ) {
$args['chapters']->the_post();
get_template_part( 'partials/_card-chapter', null, $card_args );
if ( fictioneer_get_field( 'fictioneer_chapter_hidden' ) ) {
get_template_part( 'partials/_card-hidden', null, $card_args );
} else {
get_template_part( 'partials/_card-chapter', null, $card_args );
}
}
// Actions at end of results

View File

@ -110,7 +110,12 @@ if ( ! function_exists( 'fictioneer_stories_list' ) ) {
while ( $args['stories']->have_posts() ) {
$args['stories']->the_post();
get_template_part( 'partials/_card-story', null, $card_args );
if ( fictioneer_get_field( 'fictioneer_story_hidden' ) ) {
get_template_part( 'partials/_card-hidden', null, $card_args );
} else {
get_template_part( 'partials/_card-story', null, $card_args );
}
}
// Actions at end of results

23
partials/_card-hidden.php Normal file
View File

@ -0,0 +1,23 @@
<?php
/**
* Partial: Hidden Card
*
* @package WordPress
* @subpackage Fictioneer
* @since 5.5.2
*
* @internal $args['show_type'] Whether to show the post type label. Unsafe.
* @internal $args['cache'] Whether to account for active caching. Unsafe.
* @internal $args['hide_author'] Whether to hide the author. Unsafe.
* @internal $args['order'] Current order. Default 'desc'. Unsafe.
* @internal $args['orderby'] Current orderby. Default 'modified'. Unsafe.
*/
?>
<li class="card _hidden-result">
<div class="card__body polygon">
<div class="card__main _hidden-result">
<div class="card__content _hidden-result"><?php echo _x( 'Hidden Result', 'Hidden card.', 'fictioneer' ); ?></div>
</div>
</div>
</li>

View File

@ -281,6 +281,12 @@
font-size: 13px; // Minimum desktop and mobile
line-height: 1.3;
}
&._hidden-result {
font-weight: var(--font-weight-strong);
text-align: center;
opacity: 0.25;
}
}
&__by-author {

View File

@ -10,8 +10,8 @@
* @subpackage Fictioneer
* @since 3.0
*
* @internal ('fictioneer_filter_and_search_id') ACF field. You can use this ID for plugins.
* @internal ('fictioneer_short_name') ACF field. Meant for an abbreviated page name.
* @internal ('fictioneer_filter_and_search_id') ACF field. You can use this ID for plugins.
* @internal ('fictioneer_short_name') ACF field. Meant for an abbreviated page name.
*/
?>
@ -34,18 +34,7 @@ $query_args = array (
'orderby' => "meta_value {$orderby}",
'order' => $order,
'paged' => $page,
'posts_per_page' => get_option( 'posts_per_page', 8 ),
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'fictioneer_story_hidden',
'value' => '0'
),
array(
'key' => 'fictioneer_story_hidden',
'compare' => 'NOT EXISTS'
),
)
'posts_per_page' => get_option( 'posts_per_page', 8 )
);
// Append date query (if any)