Reduce unnecessary get_the_ID calls

This commit is contained in:
Tetrakern 2023-12-02 00:00:13 +01:00
parent f02d8e2255
commit f207720f52
23 changed files with 93 additions and 89 deletions

View File

@ -18,13 +18,14 @@ if ( post_password_required() ) {
}
// Setup
$post_id = get_the_ID();
$user = wp_get_current_user();
$comments_count = get_comments_number();
$logout_url = fictioneer_get_logout_url( get_permalink() );
?>
<div id="comments" class="fictioneer-comments scroll-margin-top" data-post-id="<?php echo get_the_ID(); ?>" data-logout-url="<?php echo esc_url( $logout_url ); ?>">
<div id="comments" class="fictioneer-comments scroll-margin-top" data-post-id="<?php echo $post_id; ?>" data-logout-url="<?php echo esc_url( $logout_url ); ?>">
<?php
@ -32,7 +33,7 @@ $logout_url = fictioneer_get_logout_url( get_permalink() );
fictioneer_comments_ajax_skeleton( $comments_count ); // AJAX loading skeleton
} else {
// Query arguments
$query_args = ['post_id' => get_the_ID()];
$query_args = array( 'post_id' => $post_id );
if ( ! get_option( 'fictioneer_disable_comment_query' ) ) {
$query_args['type'] = ['comment', 'private'];
@ -42,14 +43,14 @@ $logout_url = fictioneer_get_logout_url( get_permalink() );
}
// Filter query arguments
$query_args = apply_filters( 'fictioneer_filter_comments_query', $query_args, get_the_ID() );
$query_args = apply_filters( 'fictioneer_filter_comments_query', $query_args, $post_id );
// Query comments
$comments_query = new WP_Comment_Query( $query_args );
$comments = $comments_query->comments;
// Filter comments
$comments = apply_filters( 'fictioneer_filter_comments', $comments, get_the_ID() );
$comments = apply_filters( 'fictioneer_filter_comments', $comments, $post_id );
// Comments header
fictioneer_comment_header( $comments_count );

View File

@ -68,8 +68,8 @@ $hook_args = array(
// Special conditions for chapters...
if ( $type == 'fcn_chapter' ) {
if (
get_post_meta( get_the_ID(), 'fictioneer_chapter_no_chapter', true ) ||
get_post_meta( get_the_ID(), 'fictioneer_chapter_hidden', true )
get_post_meta( $post->ID, 'fictioneer_chapter_no_chapter', true ) ||
get_post_meta( $post->ID, 'fictioneer_chapter_hidden', true )
) {
continue;
}

View File

@ -124,16 +124,16 @@ $pag_args = array(
// Setup
$story_id = ( $post->post_type === 'fcn_story' ) ? $post->ID : null;
$title = fictioneer_get_safe_title( get_the_ID() );
$title = fictioneer_get_safe_title( $post->ID );
$permalink = get_permalink();
$categories = wp_get_post_categories( get_the_ID() );
$categories = wp_get_post_categories( $post->ID );
$tags = get_the_tags();
$fandoms = get_the_terms( $post, 'fcn_fandom' );
$characters = get_the_terms( $post, 'fcn_character' );
$genres = get_the_terms( $post, 'fcn_genre' );
// Thumbnail
$landscape_image_id = get_post_meta( get_the_ID(), 'fictioneer_landscape_image', true );
$landscape_image_id = get_post_meta( $post->ID, 'fictioneer_landscape_image', true );
$thumbnail = null;
$image_args = array(
@ -147,7 +147,7 @@ $pag_args = array(
// Chapter story?
if ( $post->post_type === 'fcn_chapter' ) {
$story_id = get_post_meta( get_the_ID(), 'fictioneer_chapter_story', true );
$story_id = get_post_meta( $post->ID, 'fictioneer_chapter_story', true );
}
// Start HTML ---> ?>

View File

@ -20,13 +20,13 @@
defined( 'ABSPATH' ) OR exit;
// Setup
$title = fictioneer_get_safe_title( get_the_ID() );
$story_id = get_post_meta( get_the_ID(), 'fictioneer_chapter_story', true );
$title = fictioneer_get_safe_title( $post->ID );
$story_id = get_post_meta( $post->ID, 'fictioneer_chapter_story', true );
$story_unpublished = get_post_status( $story_id ) !== 'publish';
$story_data = $story_id ? fictioneer_get_story_data( $story_id, false ) : null; // Does not refresh comment count!
$chapter_rating = get_post_meta( get_the_ID(), 'fictioneer_chapter_rating', true );
$chapter_rating = get_post_meta( $post->ID, 'fictioneer_chapter_rating', true );
$story_thumbnail_url_full = $story_id ? get_the_post_thumbnail_url( $story_id, 'full' ) : null;
$text_icon = get_post_meta( get_the_ID(), 'fictioneer_chapter_text_icon', true );
$text_icon = get_post_meta( $post->ID, 'fictioneer_chapter_text_icon', true );
$excerpt = fictioneer_get_forced_excerpt( $post, 512, true );
// Taxonomies
@ -56,10 +56,10 @@ $show_type = $args['show_type'] ?? false;
?>
<li
id="chapter-card-<?php the_ID(); ?>"
id="chapter-card-<?php echo $post->ID; ?>"
class="card <?php echo $story_unpublished ? '_story-unpublished' : ''; ?>"
data-story-id="<?php echo $story_id; ?>"
data-check-id="<?php the_ID(); ?>"
data-check-id="<?php echo $post->ID; ?>"
>
<div class="card__body polygon">
@ -71,7 +71,7 @@ $show_type = $args['show_type'] ?? false;
<h3 class="card__title">
<a href="<?php the_permalink(); ?>" class="truncate _1-1"><?php
$list_title = wp_strip_all_tags( get_post_meta( get_the_ID(), 'fictioneer_chapter_list_title', true ) );
$list_title = wp_strip_all_tags( get_post_meta( $post->ID, 'fictioneer_chapter_list_title', true ) );
$list_title = trim( $list_title );
// Make sure there are no whitespaces in-between!
@ -86,7 +86,7 @@ $show_type = $args['show_type'] ?? false;
<?php
if ( ! empty( $story_id ) && ! empty( $story_data ) ) {
echo fictioneer_get_card_controls( $story_id, get_the_ID() );
echo fictioneer_get_card_controls( $story_id, $post->ID );
}
?>
@ -122,7 +122,7 @@ $show_type = $args['show_type'] ?? false;
'<a href="%1$s" title="%2$s" class="card__text-icon cell-img"><span class="text-icon">%3$s</span></a>',
get_permalink(),
esc_attr( $title ),
get_post_meta( get_the_ID(), 'fictioneer_chapter_text_icon', true )
get_post_meta( $post->ID, 'fictioneer_chapter_text_icon', true )
);
}
@ -191,7 +191,7 @@ $show_type = $args['show_type'] ?? false;
$footer_items['words'] = '<i class="card-footer-icon fa-solid fa-font" title="' .
esc_attr__( 'Words', 'fictioneer' ) . '"></i> ' .
fictioneer_shorten_number( fictioneer_get_word_count( get_the_ID() ) );
fictioneer_shorten_number( fictioneer_get_word_count( $post->ID ) );
if ( ( $args['orderby'] ?? 0 ) === 'date' ) {
$footer_items['publish_date'] = '<i class="card-footer-icon fa-solid fa-clock" title="' .

View File

@ -19,13 +19,13 @@
defined( 'ABSPATH' ) OR exit;
// Setup
$title = fictioneer_get_safe_title( get_the_ID() );
$title = fictioneer_get_safe_title( $post->ID );
$links = array_merge(
fictioneer_url_list_to_array( get_post_meta( get_the_ID(), 'fictioneer_recommendation_urls', true ) ),
fictioneer_url_list_to_array( get_post_meta( get_the_ID(), 'fictioneer_recommendation_support', true ) )
fictioneer_url_list_to_array( get_post_meta( $post->ID, 'fictioneer_recommendation_urls', true ) ),
fictioneer_url_list_to_array( get_post_meta( $post->ID, 'fictioneer_recommendation_support', true ) )
);
$excerpt = get_the_excerpt();
$one_sentence = get_post_meta( get_the_ID(), 'fictioneer_recommendation_one_sentence', true );
$one_sentence = get_post_meta( $post->ID, 'fictioneer_recommendation_one_sentence', true );
// Taxonomies
$tags = false;
@ -81,7 +81,7 @@ $show_type = $args['show_type'] ?? false;
'<div class="card__content cell-desc truncate _4-4"><span class="card__by-author">%1$s</span> <span>%2$s</span></div>',
sprintf(
_x( 'by %s —', 'Large card: by {Author} —.', 'fictioneer' ),
get_post_meta( get_the_ID(), 'fictioneer_recommendation_author', true )
get_post_meta( $post->ID, 'fictioneer_recommendation_author', true )
),
strlen( $one_sentence ) < strlen( $excerpt ) ? $excerpt : wp_strip_all_tags( $one_sentence, true )
);

View File

@ -48,7 +48,7 @@ $is_sticky = FICTIONEER_ENABLE_STICKY_CARDS &&
?>
<li
id="story-card-<?php the_ID(); ?>"
id="story-card-<?php echo $post->ID; ?>"
class="card <?php echo $is_sticky ? '_sticky' : ''; ?>"
data-story-id="<?php echo $post->ID; ?>"
data-check-id="<?php echo $post->ID; ?>"
@ -67,7 +67,7 @@ $is_sticky = FICTIONEER_ENABLE_STICKY_CARDS &&
<div class="card__sticky-icon" title="<?php echo esc_attr__( 'Sticky', 'fictioneer' ); ?>"><i class="fa-solid fa-thumbtack"></i></div>
<?php endif; ?>
<?php echo fictioneer_get_card_controls( get_the_ID() ); ?>
<?php echo fictioneer_get_card_controls( $post->ID ); ?>
</div>

View File

@ -113,15 +113,15 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
<?php
// Setup
$story_id = get_post_meta( get_the_ID(), 'fictioneer_chapter_story', true );
$story_id = get_post_meta( $post->ID, 'fictioneer_chapter_story', true );
if ( get_post_status( $story_id ) !== 'publish' ) {
continue;
}
$title = fictioneer_get_safe_title( get_the_ID() );
$title = fictioneer_get_safe_title( $post->ID );
$story = $story_id ? fictioneer_get_story_data( $story_id, false ) : false; // Does not refresh comment count!
$text_icon = get_post_meta( get_the_ID(), 'fictioneer_chapter_text_icon', true );
$text_icon = get_post_meta( $post->ID, 'fictioneer_chapter_text_icon', true );
// Chapter images
$thumbnail_full = get_the_post_thumbnail_url( $post, 'full' );
@ -153,7 +153,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
<?php endif; ?>
<h3 class="card__title _small cell-title"><a href="<?php the_permalink(); ?>" class="truncate _1-1"><?php
$list_title = get_post_meta( get_the_ID(), 'fictioneer_chapter_list_title', true );
$list_title = get_post_meta( $post->ID, 'fictioneer_chapter_list_title', true );
$list_title = trim( wp_strip_all_tags( $list_title ) );
echo $list_title ? $list_title : $title;

View File

@ -114,16 +114,16 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
<?php
// Setup
$story_id = get_post_meta( get_the_ID(), 'fictioneer_chapter_story', true );
$story_id = get_post_meta( $post->ID, 'fictioneer_chapter_story', true );
if ( get_post_status( $story_id ) !== 'publish' ) {
continue;
}
$title = fictioneer_get_safe_title( get_the_ID() );
$chapter_rating = get_post_meta( get_the_ID(), 'fictioneer_chapter_rating', true );
$title = fictioneer_get_safe_title( $post->ID );
$chapter_rating = get_post_meta( $post->ID, 'fictioneer_chapter_rating', true );
$story = $story_id ? fictioneer_get_story_data( $story_id, false ) : false; // Does not refresh comment count!
$text_icon = get_post_meta( get_the_ID(), 'fictioneer_chapter_text_icon', true );
$text_icon = get_post_meta( $post->ID, 'fictioneer_chapter_text_icon', true );
// Chapter images
$thumbnail_full = get_the_post_thumbnail_url( $post, 'full' );
@ -153,7 +153,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
<?php endif; ?>
<h3 class="card__title _small cell-title"><a href="<?php the_permalink(); ?>" class="truncate _1-1"><?php
$list_title = get_post_meta( get_the_ID(), 'fictioneer_chapter_list_title', true );
$list_title = get_post_meta( $post->ID, 'fictioneer_chapter_list_title', true );
$list_title = trim( wp_strip_all_tags( $list_title ) );
echo $list_title ? $list_title : $title;

View File

@ -94,7 +94,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
<?php
// Setup
$title = fictioneer_get_safe_title( get_the_ID() );
$title = fictioneer_get_safe_title( $post->ID );
$label = esc_attr( sprintf( _x( 'Continue reading %s', 'Read more link aria label', 'fictioneer' ), $title ) );
if (
@ -111,7 +111,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
<header class="post__header">
<h2 class="post__title"><a href="<?php the_permalink(); ?>"><?php echo $title; ?></a></h2>
<div class="post__meta layout-links"><?php echo fictioneer_get_post_meta_items( ['no_cat' => true] ); ?></div>
<div class="post__meta layout-links"><?php echo fictioneer_get_post_meta_items( array( 'no_cat' => true ) ); ?></div>
</header>
<section class="post__main content-section">
@ -121,10 +121,10 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
<?php if ( has_action( 'fictioneer_latest_posts_footers_left' ) || has_action( 'fictioneer_latest_posts_footers_right' ) ) : ?>
<footer class="post__footer">
<div class="post__footer-box post__footer-left">
<?php do_action( 'fictioneer_latest_posts_footers_left', get_the_ID() ); ?>
<?php do_action( 'fictioneer_latest_posts_footers_left', $post->ID ); ?>
</div>
<div class="post__footer-box post__footer-right">
<?php do_action( 'fictioneer_latest_posts_footers_right', get_the_ID() ); ?>
<?php do_action( 'fictioneer_latest_posts_footers_right', $post->ID ); ?>
</div>
</footer>
<?php endif; ?>

View File

@ -98,8 +98,8 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
<?php
// Setup
$title = fictioneer_get_safe_title( get_the_ID() );
$one_sentence = get_post_meta( get_the_ID(), 'fictioneer_recommendation_one_sentence', true );
$title = fictioneer_get_safe_title( $post->ID );
$one_sentence = get_post_meta( $post->ID, 'fictioneer_recommendation_one_sentence', true );
$fandoms = get_the_terms( $post, 'fcn_fandom' );
$characters = get_the_terms( $post, 'fcn_character' );
$genres = get_the_terms( $post, 'fcn_genre' );
@ -127,7 +127,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
<span class="card__by-author"><?php
printf(
_x( 'by %s —', 'Small card: by {Author} —.', 'fictioneer' ),
'<span class="author">' . get_post_meta( get_the_ID(), 'fictioneer_recommendation_author', true ) . '</span>'
'<span class="author">' . get_post_meta( $post->ID, 'fictioneer_recommendation_author', true ) . '</span>'
);
?></span>
<span><?php

View File

@ -99,8 +99,8 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
<?php
// Setup
$title = fictioneer_get_safe_title( get_the_ID() );
$one_sentence = get_post_meta( get_the_ID(), 'fictioneer_recommendation_one_sentence', true );
$title = fictioneer_get_safe_title( $post->ID );
$one_sentence = get_post_meta( $post->ID, 'fictioneer_recommendation_one_sentence', true );
$fandoms = get_the_terms( $post, 'fcn_fandom' );
$characters = get_the_terms( $post, 'fcn_character' );
$genres = get_the_terms( $post, 'fcn_genre' );
@ -108,8 +108,8 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
// Sources
$urls = array_merge(
explode( "\n", get_post_meta( get_the_ID(), 'fictioneer_recommendation_urls', true ) ),
explode( "\n", get_post_meta( get_the_ID(), 'fictioneer_recommendation_support', true ) )
explode( "\n", get_post_meta( $post->ID, 'fictioneer_recommendation_urls', true ) ),
explode( "\n", get_post_meta( $post->ID, 'fictioneer_recommendation_support', true ) )
);
// Sanitize
@ -146,7 +146,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
<span class="card__by-author"><?php
printf(
_x( 'by %s on', 'Small card: by {Author} on.', 'fictioneer' ),
'<span class="author">' . get_post_meta( get_the_ID(), 'fictioneer_recommendation_author', true ) . '</span>'
'<span class="author">' . get_post_meta( $post->ID, 'fictioneer_recommendation_author', true ) . '</span>'
);
?></span>
<a href="<?php echo esc_url( $tuple[1] ); ?>" rel="noopener" target="_blank" class="bold-link"><?php

View File

@ -139,7 +139,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
<?php endif; ?>
<span><?php
$short_description = fictioneer_first_paragraph_as_excerpt(
fictioneer_get_content_field( 'fictioneer_story_short_description', get_the_ID() )
fictioneer_get_content_field( 'fictioneer_story_short_description', $post->ID )
);
echo strlen( $short_description ) < 230 ? get_the_excerpt() : $short_description;
?></span>

View File

@ -132,7 +132,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
<?php endif; ?>
<span><?php
$short_description = fictioneer_first_paragraph_as_excerpt(
fictioneer_get_content_field( 'fictioneer_story_short_description', get_the_ID() )
fictioneer_get_content_field( 'fictioneer_story_short_description', $post->ID )
);
echo strlen( $short_description ) < 230 ? get_the_excerpt() : $short_description;
?></span>

View File

@ -167,7 +167,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
<?php endif; ?>
<span><?php
$short_description = fictioneer_first_paragraph_as_excerpt(
fictioneer_get_content_field( 'fictioneer_story_short_description', get_the_ID() )
fictioneer_get_content_field( 'fictioneer_story_short_description', $post->ID )
);
echo strlen( $short_description ) < 230 ? get_the_excerpt() : $short_description;
?></span>

View File

@ -169,7 +169,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
<?php endif; ?>
<span><?php
$short_description = fictioneer_first_paragraph_as_excerpt(
fictioneer_get_content_field( 'fictioneer_story_short_description', get_the_ID() )
fictioneer_get_content_field( 'fictioneer_story_short_description', $post->ID )
);
echo strlen( $short_description ) < 230 ? get_the_excerpt() : $short_description;
?></span>

View File

@ -103,16 +103,16 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
// Setup
$list_title = '';
$story_id = null;
$landscape_image_id = get_post_meta( get_the_ID(), 'fictioneer_landscape_image', true );
$landscape_image_id = get_post_meta( $post->ID, 'fictioneer_landscape_image', true );
// Get list title and story ID (if any)
switch ( $args['post_type'] ) {
case 'fcn_collection':
$list_title = get_post_meta( get_the_ID(), 'fictioneer_collection_list_title', true );
$list_title = get_post_meta( $post->ID, 'fictioneer_collection_list_title', true );
break;
case 'fcn_chapter':
$list_title = get_post_meta( get_the_ID(), 'fictioneer_chapter_list_title', true );
$story_id = get_post_meta( get_the_ID(), 'fictioneer_chapter_story', true );
$list_title = get_post_meta( $post->ID, 'fictioneer_chapter_list_title', true );
$story_id = get_post_meta( $post->ID, 'fictioneer_chapter_story', true );
if ( empty( $landscape_image_id ) ) {
$landscape_image_id = get_post_meta( $story_id, 'fictioneer_landscape_image', true );

View File

@ -15,6 +15,7 @@
<?php
// Setup
$post_id = get_the_ID();
$page = get_query_var( 'paged', 1 ) ?: 1; // Main query
$order = array_intersect( [sanitize_key( $_GET['order'] ?? 0 )], ['desc', 'asc'] );
$order = reset( $order ) ?: 'desc';
@ -39,7 +40,7 @@ $query_args = array (
$query_args = fictioneer_append_date_query( $query_args, $ago, $orderby );
// Filter query arguments
$query_args = apply_filters( 'fictioneer_filter_recommendations_query_args', $query_args, get_the_ID() );
$query_args = apply_filters( 'fictioneer_filter_recommendations_query_args', $query_args, $post_id );
// Query recommendations
$list_of_recommendations = new WP_Query( $query_args );
@ -66,12 +67,12 @@ if ( function_exists( 'update_post_author_caches' ) ) {
// Setup
$title = trim( get_the_title() );
$breadcrumb_name = empty( $title ) ? __( 'Recommendations', 'fictioneer' ) : $title;
$this_breadcrumb = [$breadcrumb_name, get_the_permalink()];
$this_breadcrumb = [ $breadcrumb_name, get_the_permalink() ];
// Arguments for hooks and templates/etc.
$hook_args = array(
'current_page' => $page,
'post_id' => get_the_ID(),
'post_id' => $post_id,
'recommendations' => $list_of_recommendations,
'queried_type' => 'fcn_recommendation',
'query_args' => $query_args,
@ -107,7 +108,7 @@ if ( function_exists( 'update_post_author_caches' ) ) {
// Footer arguments
$footer_args = array(
'post_type' => 'page',
'post_id' => get_the_ID(),
'post_id' => $post_id,
'breadcrumbs' => array(
[fcntr( 'frontpage' ), get_home_url()]
)

View File

@ -144,31 +144,33 @@ do_action( 'rss_tag_pre', 'rss2' );
<?php endif; ?>
<?php
if ( $categories = wp_get_post_categories( get_the_ID() ) ) {
$post_id = get_the_ID();
if ( $categories = wp_get_post_categories( $post_id ) ) {
foreach ( $categories as $cat ) {
echo '<category>' . get_category( $cat )->name . '</category>';
}
}
if ( $fandoms = get_the_terms( get_the_ID(), 'fcn_fandom' ) ) {
if ( $fandoms = get_the_terms( $post_id, 'fcn_fandom' ) ) {
foreach ( $fandoms as $fandom ) {
echo '<category>' . $fandom->name . '</category>';
}
}
if ( $genres = get_the_terms( get_the_ID(), 'fcn_genre' ) ) {
if ( $genres = get_the_terms( $post_id, 'fcn_genre' ) ) {
foreach ( $genres as $genre ) {
echo '<category>' . $genre->name . '</category>';
}
}
if ( $characters = get_the_terms( get_the_ID(), 'fcn_character' ) ) {
if ( $characters = get_the_terms( $post_id, 'fcn_character' ) ) {
foreach ( $characters as $character ) {
echo '<category>' . $character->name . '</category>';
}
}
if ( $tags = get_the_tags( get_the_ID() ) ) {
if ( $tags = get_the_tags( $post_id ) ) {
foreach ( $tags as $tag ) {
echo '<category>' . $tag->name . '</category>';
}

View File

@ -154,7 +154,7 @@ do_action( 'rss_tag_pre', 'rss2' );
}
// Skip invisible chapters
if ( get_post_meta( get_the_ID(), 'fictioneer_chapter_hidden', true ) ) {
if ( get_post_meta( $post->ID, 'fictioneer_chapter_hidden', true ) ) {
continue;
}
@ -184,25 +184,25 @@ do_action( 'rss_tag_pre', 'rss2' );
<?php endif; ?>
<?php
if ( $chapter_fandoms = get_the_terms( get_the_ID(), 'fcn_fandom' ) ) {
if ( $chapter_fandoms = get_the_terms( $post->ID, 'fcn_fandom' ) ) {
foreach ( $chapter_fandoms as $fandom ) {
echo '<category>' . $fandom->name . '</category>';
}
}
if ( $chapter_genres = get_the_terms( get_the_ID(), 'fcn_genre' ) ) {
if ( $chapter_genres = get_the_terms( $post->ID, 'fcn_genre' ) ) {
foreach ( $chapter_genres as $genre ) {
echo '<category>' . $genre->name . '</category>';
}
}
if ( $chapter_characters = get_the_terms( get_the_ID(), 'fcn_character' ) ) {
if ( $chapter_characters = get_the_terms( $post->ID, 'fcn_character' ) ) {
foreach ( $chapter_characters as $character ) {
echo '<category>' . $character->name . '</category>';
}
}
if ( $chapter_tags = get_the_tags( get_the_ID() ) ) {
if ( $chapter_tags = get_the_tags( $post->ID ) ) {
foreach ( $chapter_tags as $tag ) {
echo '<category>' . $tag->name . '</category>';
}

View File

@ -43,10 +43,10 @@ get_header( null, $header_args );
// Setup
$chapter_ids = [];
$password_class = ! empty( $post->post_password ) ? 'password' : '';
$title = fictioneer_get_safe_title( get_the_ID() );
$this_breadcrumb = [$title, get_the_permalink()];
$title = fictioneer_get_safe_title( $post->ID );
$this_breadcrumb = [ $title, get_the_permalink() ];
$story_id = get_post_meta( get_the_ID(), 'fictioneer_chapter_story', true );
$story_id = get_post_meta( $post->ID, 'fictioneer_chapter_story', true );
$story_data = null;
$story_post = null;
@ -61,7 +61,7 @@ get_header( null, $header_args );
}
// Chapter navigation
$current_index = array_search( get_the_ID(), $chapter_ids );
$current_index = array_search( $post->ID, $chapter_ids );
$prev_index = $current_index - 1;
$next_index = $current_index + 1;
@ -70,7 +70,7 @@ get_header( null, $header_args );
'author' => get_userdata( $post->post_author ),
'story_post' => $story_post,
'story_data' => $story_data,
'chapter_id' => get_the_ID(),
'chapter_id' => $post->ID,
'chapter_title' => $title,
'chapter_password' => $post->post_password,
'chapter_ids' => $chapter_ids,
@ -90,7 +90,7 @@ get_header( null, $header_args );
if ( get_option( 'fictioneer_enable_bookmarks' ) ) {
// Bookmark data
$bookmark_story_title = '';
$bookmark_title = get_post_meta( get_the_ID(), 'fictioneer_chapter_list_title', true );
$bookmark_title = get_post_meta( $post->ID, 'fictioneer_chapter_list_title', true );
$bookmark_title = trim( wp_strip_all_tags( $bookmark_title ) );
$bookmark_title = $bookmark_title ?: $title;
$bookmark_thumbnail = get_the_post_thumbnail_url( null, 'snippet' );
@ -145,7 +145,7 @@ get_header( null, $header_args );
do_action( 'fictioneer_chapter_after_header', $hook_args );
// Password note
$password_note = fictioneer_get_content_field( 'fictioneer_chapter_password_note', get_the_ID() );
$password_note = fictioneer_get_content_field( 'fictioneer_chapter_password_note', $post->ID );
?>
<section id="chapter-content" class="chapter__content content-section">
@ -201,7 +201,7 @@ get_header( null, $header_args );
// Footer arguments
$footer_args = array(
'post_type' => 'fcn_chapter',
'post_id' => get_the_ID(),
'post_id' => $post->ID,
'breadcrumbs' => array(
[fcntr( 'frontpage' ), get_home_url()]
)

View File

@ -33,7 +33,7 @@ get_header( null, array( 'type' => 'fcn_collection' ) );
<?php
// Setup
$featured_list = get_post_meta( get_the_ID(), 'fictioneer_collection_items', true );
$featured_list = get_post_meta( $post->ID, 'fictioneer_collection_items', true );
$featured_list = is_array( $featured_list ) ? $featured_list : [];
$title = fictioneer_get_safe_title( $post->ID );
$this_breadcrumb = [$title, get_the_permalink()];
@ -130,7 +130,7 @@ get_header( null, array( 'type' => 'fcn_collection' ) );
// Footer arguments
$footer_args = array(
'post_type' => 'fcn_collection',
'post_id' => get_the_ID(),
'post_id' => $post->ID,
'breadcrumbs' => array(
[fcntr( 'frontpage' ), get_home_url()]
)

View File

@ -26,8 +26,8 @@ get_header();
<?php
// Setup
$title = fictioneer_get_safe_title( get_the_ID() );
$this_breadcrumb = [$title, get_the_permalink()];
$title = fictioneer_get_safe_title( $post->ID );
$this_breadcrumb = [ $title, get_the_permalink() ];
?>
<article id="post-<?php the_ID(); ?>" class="post__article padding-left padding-right padding-top padding-bottom">
@ -39,15 +39,15 @@ get_header();
<section class="post__main content-section"><?php the_content(); ?></section>
<?php do_action( 'fictioneer_post_after_content', get_the_ID() ); ?>
<?php do_action( 'fictioneer_post_after_content', $post->ID ); ?>
<?php if ( ! post_password_required() && ( has_action( 'fictioneer_post_footer_left' ) || has_action( 'fictioneer_post_footer_right' ) ) ) : ?>
<footer class="post__footer">
<div class="post__footer-box post__footer-left">
<?php do_action( 'fictioneer_post_footer_left', get_the_ID() ); ?>
<?php do_action( 'fictioneer_post_footer_left', $post->ID ); ?>
</div>
<div class="post__footer-box post__footer-right">
<?php do_action( 'fictioneer_post_footer_right', get_the_ID() ); ?>
<?php do_action( 'fictioneer_post_footer_right', $post->ID ); ?>
</div>
</footer>
<?php endif; ?>
@ -70,7 +70,7 @@ get_header();
// Footer arguments
$footer_args = array(
'post_type' => 'post',
'post_id' => get_the_ID(),
'post_id' => $post->ID,
'breadcrumbs' => array(
[fcntr( 'frontpage' ), get_home_url()]
)

View File

@ -84,12 +84,12 @@ if ( function_exists( 'update_post_author_caches' ) ) {
// Setup
$title = trim( get_the_title() );
$breadcrumb_name = empty( $title ) ? __( 'Stories', 'fictioneer' ) : $title;
$this_breadcrumb = [$breadcrumb_name, get_the_permalink()];
$this_breadcrumb = [ $breadcrumb_name, get_the_permalink() ];
// Arguments for hooks and templates/etc.
$hook_args = array(
'current_page' => $page,
'post_id' => get_the_ID(),
'post_id' => $post->ID,
'stories' => $list_of_stories,
'queried_type' => 'fcn_story',
'query_args' => $query_args,
@ -128,7 +128,7 @@ if ( function_exists( 'update_post_author_caches' ) ) {
// Footer arguments
$footer_args = array(
'post_type' => 'page',
'post_id' => get_the_ID(),
'post_id' => $post->ID,
'current_page' => $page,
'stories' => $list_of_stories,
'breadcrumbs' => array(