Update from Git Manager GUI
This commit is contained in:
112
templates/single-wmw_article.php
Normal file
112
templates/single-wmw_article.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
if ( ! defined( 'ABSPATH' ) ) { exit; }
|
||||
get_header();
|
||||
while ( have_posts() ) :
|
||||
the_post();
|
||||
$post_id = get_the_ID();
|
||||
$wiki_id = get_post_meta( $post_id, '_wmw_wiki_id', true );
|
||||
$color = $wiki_id ? ( get_post_meta( $wiki_id, '_wmw_color', true ) ?: '#0073aa' ) : '#0073aa';
|
||||
|
||||
// Naechster / Vorheriger Artikel laden
|
||||
$siblings = [];
|
||||
if ( $wiki_id ) {
|
||||
$siblings = get_posts( [
|
||||
'post_type' => 'wmw_article',
|
||||
'numberposts' => -1,
|
||||
'post_status' => 'publish',
|
||||
'meta_key' => '_wmw_wiki_id',
|
||||
'meta_value' => $wiki_id,
|
||||
'orderby' => [ 'meta_value_num' => 'ASC', 'title' => 'ASC' ],
|
||||
] );
|
||||
}
|
||||
$prev_art = null; $next_art = null;
|
||||
foreach ( $siblings as $i => $s ) {
|
||||
if ( $s->ID === $post_id ) {
|
||||
if ( $i > 0 ) $prev_art = $siblings[ $i - 1 ];
|
||||
if ( $i < count( $siblings ) - 1 ) $next_art = $siblings[ $i + 1 ];
|
||||
break;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="wmw-page-article" style="--wmw-color: <?php echo esc_attr( $color ); ?>;">
|
||||
|
||||
<div class="wmw-article-layout">
|
||||
|
||||
<!-- Sidebar Navigation -->
|
||||
<aside class="wmw-sidebar" id="wmw-sidebar">
|
||||
<?php if ( $wiki_id ) : ?>
|
||||
<div class="wmw-sidebar-header">
|
||||
<a href="<?php echo esc_url( get_permalink( $wiki_id ) ); ?>" class="wmw-sidebar-wiki-link">
|
||||
<span class="dashicons dashicons-arrow-left-alt"></span>
|
||||
<?php echo esc_html( get_the_title( $wiki_id ) ); ?>
|
||||
</a>
|
||||
</div>
|
||||
<div class="wmw-sidebar-search">
|
||||
<?php echo do_shortcode( '[wmw_search wiki_id="' . $wiki_id . '"]' ); ?>
|
||||
</div>
|
||||
<?php echo WMW_Frontend::render_wiki_content( $wiki_id, false ); ?>
|
||||
<?php endif; ?>
|
||||
</aside>
|
||||
|
||||
<!-- Artikel-Inhalt -->
|
||||
<main class="wmw-article-content" id="wmw-content">
|
||||
<?php echo do_shortcode( '[wmw_breadcrumb]' ); ?>
|
||||
|
||||
<article>
|
||||
<header class="wmw-article-header">
|
||||
<h1><?php the_title(); ?></h1>
|
||||
<div class="wmw-article-meta">
|
||||
<span class="wmw-updated">
|
||||
Aktualisiert: <?php echo esc_html( get_the_modified_date() ); ?>
|
||||
</span>
|
||||
<?php
|
||||
$tags = wp_get_post_terms( $post_id, 'wmw_tag' );
|
||||
if ( ! is_wp_error( $tags ) && ! empty( $tags ) ) :
|
||||
?>
|
||||
<div class="wmw-tags">
|
||||
<?php foreach ( $tags as $tag ) : ?>
|
||||
<a href="<?php echo esc_url( get_term_link( $tag ) ); ?>"
|
||||
class="wmw-tag">#<?php echo esc_html( $tag->name ); ?></a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="wmw-article-body">
|
||||
<?php the_content(); ?>
|
||||
</div>
|
||||
|
||||
<!-- Navigation: Prev / Next -->
|
||||
<?php if ( $prev_art || $next_art ) : ?>
|
||||
<nav class="wmw-article-nav">
|
||||
<?php if ( $prev_art ) : ?>
|
||||
<a href="<?php echo esc_url( get_permalink( $prev_art->ID ) ); ?>"
|
||||
class="wmw-nav-prev">
|
||||
<span class="dashicons dashicons-arrow-left-alt2"></span>
|
||||
<span>
|
||||
<em>Zurueck</em>
|
||||
<strong><?php echo esc_html( $prev_art->post_title ); ?></strong>
|
||||
</span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php if ( $next_art ) : ?>
|
||||
<a href="<?php echo esc_url( get_permalink( $next_art->ID ) ); ?>"
|
||||
class="wmw-nav-next">
|
||||
<span>
|
||||
<em>Weiter</em>
|
||||
<strong><?php echo esc_html( $next_art->post_title ); ?></strong>
|
||||
</span>
|
||||
<span class="dashicons dashicons-arrow-right-alt2"></span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</nav>
|
||||
<?php endif; ?>
|
||||
</article>
|
||||
</main>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php endwhile; ?>
|
||||
<?php get_footer(); ?>
|
||||
Reference in New Issue
Block a user