Auf meiner Startseite werden die Posts getrennt nach Kategorie dargestellt.
PHP
<?php
$i = 0;
$cat1 = $cat2 = $cat3 = $cat4 = $cat5 = $cat6 = $cat7 = Array();
if (have_posts()) : while (have_posts()) : the_post();
if ( in_category( 'neuigkeit' ) ) {
$cat1[ $i ]['the_title'] = get_the_title();
$cat1[ $i ]['the_content'] = get_the_content();
$cat1[ $i ]['the_permalink'] = get_permalink();
$cat1[ $i ]['the_ID'] = get_the_ID();
}
if ( in_category( 'geschichte' ) ) {
$cat2[ $i ]['the_title'] = get_the_title();
$cat2[ $i ]['the_excerpt'] = get_the_excerpt();
$cat2[ $i ]['the_permalink'] = get_permalink();
$cat2[ $i ]['the_ID'] = get_the_ID();
} // usw.
Alles anzeigen
Meine erste Kategorie, "Neuigkeit" wird dann folgendermassen aufgerufen:
PHP
foreach( $cat1 as $post ) { ?>
<article class="entry-content">
<h2><?php _e("<!--:rm-->Eveniments<!--:--><!--:de-->Ereignisse<!--:-->"); ?></h2>
<h3><?php echo $post['the_title']; ?></h3>
<?php echo get_the_post_thumbnail( $post['the_ID'], 'medium' ); ?>
<p><?php echo $post['the_content']; ?></p>
<p class="byline vcard">
<?php printf( __( '<time class="updated" datetime="%1$s" pubdate>%2$s</time>', 'bonestheme' ), get_the_time('Y-m-j'), get_the_time(get_option('date_format')), get_the_author_link( get_the_author_meta( 'ID' ) )); ?>
</p>
</article>
Das Problem dabei ist, dass hier immer nur der älteste Artikel dargestellt wird, ich möchte aber nur den neuesten darstellen. Wie kann ich dies noch anpassen?
Danke