dbenjamin
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Themes and Templates
In reply to: Conditional get_template_partHello,
I’ll do that, thank you ??
br,
Benjamin.Forum: Themes and Templates
In reply to: Conditional get_template_partI can’t do that into the loop because the two sections are separated in real context.
The home page is too complex and i need two different loops to get posts from “News” category and the others.
I tried to do :
<section id="page"> <section id="news" class="articles-bloc"> <h2>News</h2> <ul> <?php $posts = get_posts('category_name=news&numberposts=5&orderby=date'); ?> <?php foreach($posts as $post) : ?> <?php setup_postdata($post); ?> <li id="news-<?php the_ID(); ?>"> <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Voir : %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a> </li> <?php endforeach; ?> </ul> </section> <section id="articles" class="articles-bloc"> <h2>Articles</h2> <?php /* Run the loop to output the posts. * If you want to overload this in a child theme then include a file * called loop-index.php and that will be used instead. */ get_template_part( 'loop', 'index' ); ?> </section> </section>
And into the loop :
<?php while ( have_posts() ) : the_post(); ?> <?php if ( ! in_category('news') ) : ?> <article ..... <?php endif; ?> <?php endwhile; ?>
I’ve got the news but nothing into “articles”. Don’t know why. Do i need to reset something before entering the loop ?
Thanks.
br,
Benjamin.
Viewing 2 replies - 1 through 2 (of 2 total)