Hallo zusammen,
ich habe ein ähnliches Problem.
Ich möchte eine Seite generieren, die mir die Beiträge einer Kategorie verkürzt und mit einem "weiterlesen"-Link anzeigt. Die Seite sollte als Übersichtsseite dienen, auf die man über den Menüpunkt der Hauptkategorie gelangt. Ich benutze ein Childtheme des Twenty Sixteen Themes.
Ich habe mittlerweile folgendes gemacht:
- die page.php des originalen Themes kopiert und neu unter meinem Childtheme abgespeichert.
- aus der archive.php habe ich den zweiten Loop kopiert und in meine neu generierte Seite unter den ersten Loop eingefügt.
- zwischen die beiden Loops habe ich dann definiert welche Kategorie und wie viele Beitrage angezeigt werden sollen.
Laut Beschreibung sollte alles funktionieren..tut es bei mir leider nicht.
Kann es sein, dass ich diese neue Seite im Backend iwie mit der Kategorie verbinden muss?
Oder gibt es eine andere Methode die ich verwenden kann?
Ich wäre um jede Hilfe dankbar!
Hier mein Code:
<?php
/**
* The template for displaying pages
*
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages and that
* other "pages" on your WordPress site will use a different template.
*
* @package WordPress
* @subpackage Twenty_Sixteen
* @since Twenty Sixteen 1.0
*/
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
// Start the loop.
while ( have_posts() ) : the_post();
// Include the page content template.
get_template_part( 'template-parts/content', 'page' );
// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) {
comments_template();
}
// End of the loop.
endwhile;
?>
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'category_name' => 'aktuelle-ausgabe',
'paged' => $paged,
'posts_per_page' => 2
);
query_posts($args); ?>
<?php
// Start the Loop.
while ( have_posts() ) : the_post();
/*
* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'template-parts/content', get_post_format() );
// End the loop.
endwhile;
// Previous/next page navigation.
the_posts_pagination( array(
'prev_text' => __( 'Previous page', 'twentysixteen' ),
'next_text' => __( 'Next page', 'twentysixteen' ),
'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentysixteen' ) . ' </span>',
) );
// If no content, include the "No posts found" template.
else :
get_template_part( 'template-parts/content', 'none' );
endif;
?>
</main><!-- .site-main -->
<?php get_sidebar( 'content-bottom' ); ?>
</div><!-- .content-area -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Alles anzeigen