Guten Morgen liebe Leute,
ich hab mal wieder ein Problem, sitze jetzt schon ein paar Stunden daran und habe gefühlte 100 Lösungsmöglichkeiten ausprobiert, die mir Google und dieses Forum vorgegeben hat. Doch leider will nichts so richtig funktionieren.
Ich habe eine Webseite mit Wordpress erstellt (k2-Theme) und habe darin zwei Blogseiten auf denen jeweils unterschiedliche Kategorien angezeigt werden sollen. Einerseits geht es um Projekte, hier habe den Standardblog verwendet und alles funktioniert einwandfrei.
Den eigentlichen Blog wollte ich dann auf eine statische Seite verlagern. Habe also ein neues Seitentemplate angelegt und darin den von k2 verschachtelten (-.-) Loop positioniert.
Mittlerweile habe ich auch herausgefunden, dass ich die Pagination erstmal aktivieren muss. Habe also folgenden Code davor gesetzt:
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts('cat=1,3,4,5,7&paged=$paged&posts_per_page=5');
?>
Leider funktioniert das Ganze trotzdem nicht. Ich dachte dann, dass es evtl. an k2 liegt und habe die im loop angezeigt includes direkt hineinkopiert und dann den obigen Code vor dem eigentlichen Loop platziert (riesiger Code-Batzen):
<?php
// This is the loop, which fetches entries from your database.
// It is a very delicate piece of machinery. Be gentle!
global $wp_query;
// array for loading loop templates
$templates = array();
$page_head = '';
if ( is_home() ) {
$templates[] = 'blocks/k2-loop-home.php';
} elseif ( is_archive() ) {
if ( is_date() ) {
the_post();
if ( is_day() ) {
$templates[] = 'blocks/k2-loop-archive-day.php';
$page_head = sprintf( __('Daily Archive for %s','k2_domain'), get_the_time( __('F jS, Y','k2_domain') ) );
} elseif ( is_month() ) {
$templates[] = 'blocks/k2-loop-archive-month.php';
$page_head = sprintf( __('Monthly Archive for %s','k2_domain'), get_the_time( __('F, Y','k2_domain') ) );
} elseif ( is_year() ) {
$templates[] = 'blocks/k2-loop-archive-year.php';
$page_head = sprintf( __('Yearly Archive for %s','k2_domain'), get_the_time( __('Y','k2_domain') ) );
}
$templates[] = 'blocks/k2-loop-archive-date.php';
rewind_posts();
} elseif ( is_category() ) {
$templates[] = 'blocks/k2-loop-category-' . absint( get_query_var('cat') ) . '.php';
$templates[] = 'blocks/k2-loop-category.php';
$page_head = sprintf( __('Archive for the \'%s\' Category','k2_domain'), single_cat_title('', false) );
} elseif ( is_tag() ) {
$templates[] = 'blocks/k2-loop-tag-' . get_query_var('tag') . '.php';
$templates[] = 'blocks/k2-loop-tag.php';
$page_head = sprintf( __('Tag Archive for \'%s\'','k2_domain'), single_tag_title('', false) );
} elseif ( is_author() ) {
$templates[] = 'blocks/k2-loop-author.php';
$page_head = sprintf( __('Author Archive for %s','k2_domain'), get_author_name( get_query_var('author') ) );
}
$templates[] = 'blocks/k2-loop-archive.php';
} elseif ( is_search() ) {
$templates[] = 'blocks/k2-loop-search.php';
$page_head = sprintf( __('Search Results for \'%s\'','k2_domain'), esc_attr( get_search_query() ) );
}
$templates[] = 'blocks/k2-loop.php';
?>
<?php /* Top Navigation */ k2_navigation('nav-above'); ?>
<?php if ( ! empty($page_head) ): ?>
<div class="page-head">
<h1><?php echo $page_head; ?></h1>
<?php if ( is_paged() ): ?>
<h2 class="archivepages"><?php printf( __('Page %1$s of %2$s', 'k2_domain'), intval( get_query_var('paged')), $wp_query->max_num_pages); ?></h2>
<?php endif; ?>
</div>
<?php endif; ?>
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts('cat=1,3,4,5,7&paged=$paged&posts_per_page=5');
?>
<?php while ( have_posts() ): the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="entry-head">
<h3 class="entry-title">
<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php k2_permalink_title(); ?>">
<div class="entry-cat"><?php foreach((get_the_category()) as $cat)
{ echo '<img src="http://hockhart.com/salzigdesign/wp-content/themes/salzigdesign/images/' . $cat->cat_name . '.png"
alt="' . $cat->cat_name . '" />'; } ?></div>
<div style="padding-top:2px;float:left;"><?php the_title(); ?></div></a>
<div style="float: right; position: relative; padding-top: 3px; margin-right: -3px;"><span class='st_sharethis' st_title='{title}' st_url='{url}' displayText=''></span></div>
</h3>
<?php /* Edit Link */ edit_post_link( __('Edit','k2_domain'), '<span class="entry-edit">', '</span>' ); ?>
<?php if ( 'post' == $post->post_type ): ?>
<?php endif; ?>
<?php /* K2 Hook */ do_action('template_entry_head'); ?>
</div><!-- .entry-head -->
<div class="entry-content">
<?php if ( function_exists('has_post_thumbnail') and has_post_thumbnail() ): ?>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( array( 75, 75 ), array( 'class' => 'alignleft' ) ); ?></a>
<?php endif; ?>
<?php the_content( sprintf( __('Continue reading \'%s\'', 'k2_domain'), the_title('', '', false) ) ); ?>
</div><!-- .entry-content -->
<div class="entry-foot">
<?php wp_link_pages( array('before' => '<div class="entry-pages"><span>' . __('Pages:','k2_domain') . '</span>', 'after' => '</div>' ) ); ?>
<?php if ( 'post' == $post->post_type ): ?>
<div class="entry-meta">
<?php k2_entry_meta(2); ?>
</div><!-- .entry-meta -->
<?php endif; ?>
<?php /* K2 Hook */ do_action('template_entry_foot'); ?>
</div><!-- .entry-foot -->
</div><!-- #post-ID -->
<?php endwhile; /* End The Loop */ ?>
Alles anzeigen
Irgendwie habe ich jetzt ein wenig den Überblick verloren. An der Pagination selbst liegt es nicht, da ich hier das Pagebar Plugin verwende und das beim normalen Loop ja einwandfrei funktioniert. Habs außerdem auch schon mit der normalen Pagination versucht, nix geht. :(
Ich hoffe, mir kann hier jemand helfen... Vielen Dank schon mal im Voraus.
Fabian