WordPress HowTo - die Startseite, Teil4
05/2008

Okay, hier kommt das erste praxistaugliche Beispiel einer Startseite, eignet sich sehr gut für ein Blog mit eigener News-Kategorie.

Zeige den letzten Artikel einer Kategorie im laufenden Monat komplett, danach alle anderen (des laufenden Monats) dieser Kategorie nur mit Titel:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php $current_month = date('m'); ?>
<?php $current_year = date('Y'); ?>
<?php query_posts("cat=1&year=$current_year&monthnum=$current_month&showposts=1&order=DESC"); ?>
 
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
 
<h2>Aktuelle News:</h2>
 
<div class="post">
<h2 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link zu Post '<?php the_title_attribute(); ?>'"><?php the_title(); ?></a><br />
<span class="date"><?php the_time('m/Y') ?></span></h2>
 
<div class="entry">
<?php the_content(); ?>
</div>
 
<div class="meta">
<?php echo 'Rubrik: '; the_category(', '); ?> | <?php the_tags('Tags: ', ', ', '<br />'); ?>
<?php comments_popup_link('(0) Kommentare', '(1) Kommentar', '(%) Kommentare'); ?>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
 
<h2>Alle News dieses Monats im Überblick:</h2>
 
<ul>
<?php query_posts("cat=1&year=$thispostsyear&monthnum=$thispostsmonth&showposts=-1&order=DESC"); ?>
 
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link zu Post '<?php the_title_attribute(); ?>'"><?php the_title(); ?></a><br />
gepostet von <?php the_author() ?> am <?php the_time('d.m.Y'); ?></li>
<?php endwhile; ?>
<?php endif; ?>
</ul>

--- ende artikel ---------------------------

kOmMeNtaR sChReIbEn:



*


* (keine Veröffentlichung)


  • tRaNsLaTe:

    German flag  English flag  French flag  Spanish flag  
  • ... kLeInE hElFeRlEiN:

  • bLoGpRoFi?

    • Bloggerjobs besuchen und
      zusätzliches Geld verdienen!

  • "Ich mag verdammen, was du sagst, aber ich werde mein Leben dafür einsetzen, dass du es sagen darfst." (Voltaire)