Add Story Mirror page template

This commit is contained in:
Tetrakern 2024-05-09 23:56:51 +02:00
parent ba878ba4eb
commit dcfd17dd1b
3 changed files with 34 additions and 2 deletions

View File

@ -8,7 +8,9 @@ Click the outline toggle in the top-right corner to see the table of contents.
You may want to set up a front page like the demo site or make it a landing page in case of a single-story site. Both can be achieved with blocks, shortcodes, and some custom CSS or HTML if necessary. Obviously, you can always add a custom page template in your child theme if you have the skill for that, which can look like pretty much anything.
Under **Settings > Reading**, set **Your homepage displays** to "A static page" and assign your **Homepage** and **Posts page**. Create new pages if you did not already, give them sensible names. For your **Homepage**, choose the "No Title Page" or "Story Page" page template. The latter is for single-story sites and has more shortcode options, plus a meta field for a story ID that is only used with this template. If you want to treat your Homepage as singular story page and not show the actual story post, you can set a redirect in the story to your base address.
Under **Settings > Reading**, set **Your homepage displays** to "A static page" and assign your **Homepage** and **Posts page**. Create new pages if you did not already, give them sensible names. For your **Homepage**, choose the "No Title Page" or "Story Page" page template.
The "Story Page" template is for single-story sites and has more shortcode options, plus meta fields for the story ID and header. Alternatively, you can choose the "Story Mirror" template, which will mirror the story post of the specified story ID. If you want to treat your Homepage as singular page and not show the actual story post, you can set a redirect in the story to your base address.
For simplicity, here is the copied content of the [demo homepage](https://fictioneer-theme.com/) and [demo story page](https://fictioneer-theme.com/story-page/). Put that into the code editor view and adjust it as needed (the IDs will be obviously different for you). When you switch back to the visual editor, everything should be properly formatted as blocks.

View File

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

25
singular-mirror-story.php Normal file
View File

@ -0,0 +1,25 @@
<?php
/**
* Template Name: Story Mirror
*
* @package WordPress
* @subpackage Fictioneer
* @since 5.17.0
* @see partials/_story-header.php
* @see partials/_story-footer.php
*/
?>
<?php
// Setup
$post_id = get_post_meta( get_the_ID(), 'fictioneer_template_story_id', true );
$post_id = fictioneer_validate_id( $post_id, 'fcn_story' );
if ( ! $post_id ) {
wp_die( __( 'Invalid or missing story ID in page template.', 'fictioneer' ) );
}
$post = get_post( $post_id );
get_template_part( 'single-fcn_story', null, array( 'post_id' => $post_id ) );