Ich bin dabei für einige meiner Kategorien eigene category-x.php zu erstellen.
Da ich bei einigen Kategorien das selbe Design wie in der index.php benötige, habe ich mir gedacht, kopierst einfach mal den Code und fügst ihn in die erforderliche category-x.php.
Das dumme daran ist nun, das trotzdem nur der Code-Block der letzten Artikel angezeigt wird aber nicht meine Highlight-Ausgabe.
Meine Frage ist nun - Wieso wird nur ein Teil des Codes ausgeführt? Gibt WP vor welcher Code in einer Kategorie ausgeführt werden kann oder nicht?
Anbei der Code meiner index.php welchen ich auch in meiner category-x.php nutzen möchte
PHP
<?php get_header(); ?>
<!-- Left // -->
<div class="left">
<?php if (have_posts()) : ?>
<?php if(is_home() && !get_query_var('paged')) : ?>
<!-- Highlights // -->
<span class="heading2"><span>Highlights</span></span>
<ul class="highlights">
<?php $highlight1 = new WP_Query("meta_key=thumbnail&cat=".get_wpn_config('highlights_category_id_1')."&showposts=1"); while($highlight1->have_posts()) : $highlight1->the_post();?>
<li>
<?php if(get_post_meta($post->ID, "thumbnail", true)) : ?>
<a href="<?php the_permalink(); ?>" class="thumbnail"><img src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" /></a>
<?php endif; ?>
<span class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span>
<span class="cat"><?php the_category(', '); ?></span>
</li>
<?php endwhile; ?>
<?php $highlight2 = new WP_Query("meta_key=thumbnail&cat=".get_wpn_config('highlights_category_id_2')."&showposts=1"); while($highlight2->have_posts()) : $highlight2->the_post();?>
<li>
<?php if(get_post_meta($post->ID, "thumbnail", true)) : ?>
<a href="<?php the_permalink(); ?>" class="thumbnail"><img src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" /></a>
<?php endif; ?>
<span class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span>
<span class="cat"><?php the_category(', '); ?></span>
</li>
<?php endwhile; ?>
<?php $highlight3 = new WP_Query("meta_key=thumbnail&cat=".get_wpn_config('highlights_category_id_3')."&showposts=1"); while($highlight3->have_posts()) : $highlight3->the_post();?>
<li>
<?php if(get_post_meta($post->ID, "thumbnail", true)) : ?>
<a href="<?php the_permalink(); ?>" class="thumbnail"><img src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" /></a>
<?php endif; ?>
<span class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span>
<span class="cat"><?php the_category(', '); ?></span>
</li>
<?php endwhile; ?>
</ul>
<div class="clear"></div>
<!-- // Highlights -->
<?php endif; ?>
<!-- Latest Articles // -->
<span class="heading2"><span><?php echo $_GET['paged'] ? 'Page'.$_GET['paged'] : 'Latest Articles'; ?></span></span>
<ul class="articles">
<?php while (have_posts()) : the_post(); ?>
<li id="post-<?php the_ID(); ?>">
<a class="title" href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<span class="pinfo">
<a class="comments" href="<?php the_permalink() ?>#comments"><?php comments_number(__('No Comments'), __('1 Comment'), __('% Comments')); ?></a>Geschrieben von <?php the_author_posts_link() ?> am <?php the_date(); ?> in <span><?php the_category(', ') ?></span>
</span>
<?php if(get_post_meta($post->ID, "thumbnail", true)) : ?>
<a href="<?php the_permalink(); ?>" class="thumb"><img src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" /></a>
<?php endif; ?>
<div class="post">
<?php wpn_content_limit(get_the_content(),400); ?> <a href="<?php the_permalink(); ?>">more</a>.
</div>
<div class="clear"></div>
</li>
<?php endwhile; ?>
</ul>
<!-- // News List -->
<!-- Page Navigation -->
<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>
<br />
<div class="clear"></div>
<?php if(is_home() && !get_query_var('paged')) : ?>
<!-- Highlights // -->
<span class="heading2"><span>Highlights</span></span>
<ul class="highlights">
<?php $highlight4 = new WP_Query("meta_key=thumbnail&cat=".get_wpn_config('highlights_category_id_4')."&showposts=1"); while($highlight4->have_posts()) : $highlight4->the_post();?>
<li>
<?php if(get_post_meta($post->ID, "thumbnail", true)) : ?>
<a href="<?php the_permalink(); ?>" class="thumbnail"><img src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" /></a>
<?php endif; ?>
<span class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span>
<span class="cat"><?php the_category(', '); ?></span>
</li>
<?php endwhile; ?>
<?php $highlight5 = new WP_Query("meta_key=thumbnail&cat=".get_wpn_config('highlights_category_id_5')."&showposts=1"); while($highlight5->have_posts()) : $highlight5->the_post();?>
<li>
<?php if(get_post_meta($post->ID, "thumbnail", true)) : ?>
<a href="<?php the_permalink(); ?>" class="thumbnail"><img src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" /></a>
<?php endif; ?>
<span class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span>
<span class="cat"><?php the_category(', '); ?></span>
</li>
<?php endwhile; ?>
<?php $highlight6 = new WP_Query("meta_key=thumbnail&cat=".get_wpn_config('highlights_category_id_6')."&showposts=1"); while($highlight6->have_posts()) : $highlight6->the_post();?>
<li>
<?php if(get_post_meta($post->ID, "thumbnail", true)) : ?>
<a href="<?php the_permalink(); ?>" class="thumbnail"><img src="<?php echo get_post_meta($post->ID, "thumbnail", true); ?>" /></a>
<?php endif; ?>
<span class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span>
<span class="cat"><?php the_category(', '); ?></span>
</li>
<?php endwhile; ?>
</ul>
<div class="clear"></div>
<!-- // Highlights -->
<?php endif; ?>
<!-- 404 Error -->
<?php else : include ('editable/404/404-error.php'); endif; ?>
<div class="wpn_clear"></div>
</div>
<!-- // Left -->
<?php get_sidebar('1'); ?>
<?php get_footer(); ?>
Alles anzeigen