Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

ok I'm pretty new to wordpress and the codex seems too complicated for a newbie like me. My homepage has both a slider(which I want it to display 5 latest post) and a carousel(which should display 4 older post)

I know wordpress uses the query_post() function to display the posts but my problem is how to employ this function in both the carousel and the slider (which are both on the homepage). :(

share|improve this question

1 Answer 1

You want get_posts not query_posts. Only use the latter if you need to modify the main query.

Something like this (in whatever template file you want):

<ul class="slider">
<?php
global $post;
$args = array( 'numberposts' => 5, 'order'=> 'ASC', 'orderby' => 'title' );
$myposts = get_posts( $args );
foreach( $myposts as $post ) :
    setup_postdata($post); 
?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>

Rinse, lather, repeat with necessary parameters for carousel.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.