Some post author cache optimizations

This commit is contained in:
Tetrakern 2023-08-06 21:33:37 +02:00
parent ec0c278653
commit 7599fa25b0
4 changed files with 11 additions and 8 deletions

View File

@ -55,7 +55,11 @@ if ( ! function_exists( 'fictioneer_get_card_list' ) ) {
$query = new WP_Query( $the_query_args );
// Prime author cache
if ( ! empty( $query->posts ) && function_exists( 'update_post_author_caches' ) ) {
if (
get_option( 'fictioneer_show_authors' ) &&
! empty( $query->posts ) &&
function_exists( 'update_post_author_caches' )
) {
update_post_author_caches( $query->posts );
}
}

View File

@ -20,7 +20,11 @@ if ( ! function_exists( 'fictioneer_shortcode_query' ) ) {
$result = new WP_Query( $args );
// Prime author cache
if ( ! empty( $result->posts ) && function_exists( 'update_post_author_caches' ) ) {
if (
get_option( 'fictioneer_show_authors' ) &&
! empty( $result->posts ) &&
function_exists( 'update_post_author_caches' )
) {
update_post_author_caches( $result->posts );
}

View File

@ -152,11 +152,6 @@ $disable_folding = fictioneer_get_field( 'fictioneer_story_disable_collapse' );
)
);
// Prime author cache
if ( function_exists( 'update_post_author_caches' ) ) {
update_post_author_caches( $chapter_query->posts );
}
// Prepare chapter groups
if ( $chapter_query->have_posts() ) {
while( $chapter_query->have_posts() ) {

View File

@ -77,7 +77,7 @@
$featured_query = new WP_Query( $query_args );
// Prime author cache
if ( function_exists( 'update_post_author_caches' ) ) {
if ( ! empty( $featured_query->posts ) && function_exists( 'update_post_author_caches' ) ) {
update_post_author_caches( $featured_query->posts );
}