Add singular-story page template

This commit is contained in:
Tetrakern 2024-04-14 12:47:39 +02:00
parent d67e8c7292
commit 0787283099
3 changed files with 81 additions and 3 deletions

View File

@ -656,7 +656,7 @@ if ( ! is_admin() ) {
*/
function fictioneer_conditional_require_frontend_hooks() {
if ( is_page_template( 'stories.php' ) || is_singular( 'fcn_story' ) ) {
if ( is_page_template( 'stories.php' ) || is_page_template( 'singular-story.php' ) || is_singular( 'fcn_story' ) ) {
require_once __DIR__ . '/includes/functions/hooks/_story_hooks.php';
}

View File

@ -660,7 +660,7 @@ function fictioneer_style_queue() {
}
// Story
if ( $post_type == 'fcn_story' ) {
if ( $post_type == 'fcn_story' || is_page_template( 'singular-story.php' ) ) {
wp_enqueue_style(
'fictioneer-story',
get_template_directory_uri() . '/css/story.css',
@ -1044,7 +1044,7 @@ function fictioneer_add_custom_scripts() {
}
// Enqueue story
if ( $post_type == 'fcn_story' && ! is_archive() && ! is_search() ) {
if ( ( $post_type == 'fcn_story' || is_page_template( 'singular-story.php' ) ) && ! is_archive() && ! is_search() ) {
wp_enqueue_script( 'fictioneer-story-scripts' );
}

78
singular-story.php Normal file
View File

@ -0,0 +1,78 @@
<?php
/**
* Template Name: Story Page
*
* @package WordPress
* @subpackage Fictioneer
* @since 5.14.0
* @see comments.php
*/
?>
<?php
// Setup
$post_id = get_the_ID();
// Header
get_header();
?>
<main id="main" class="main singular">
<div class="observer main-observer"></div>
<?php do_action( 'fictioneer_main' ); ?>
<div class="main__background polygon polygon--main background-texture"></div>
<div class="main__wrapper">
<?php do_action( 'fictioneer_main_wrapper' ); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
// Setup
$title = fictioneer_get_safe_title( $post_id, 'singular-story' );
$this_breadcrumb = [ $title, get_the_permalink() ];
?>
<article id="singular-<?php echo $post_id; ?>" class="singular__article padding-left padding-right padding-top padding-bottom">
<section class="singular__content content-section"><?php the_content(); ?></section>
<footer class="singular__footer"><?php do_action( 'fictioneer_singular_footer' ); ?></footer>
</article>
<?php do_action( 'fictioneer_before_comments' ); ?>
<?php if ( comments_open() && ! post_password_required() ) : ?>
<section class="singular__comments comment-section padding-left padding-right padding-bottom">
<?php comments_template(); ?>
</section>
<?php endif; ?>
<?php endwhile; ?>
</div>
</main>
<?php
// Footer arguments
$footer_args = array(
'post_type' => 'page',
'post_id' => $post_id,
'breadcrumbs' => array(
[fcntr( 'frontpage' ), get_home_url()]
)
);
// Add current breadcrumb
$footer_args['breadcrumbs'][] = $this_breadcrumb;
// Get footer with breadcrumbs
get_footer( null, $footer_args );
?>