Help with WordPress Query

I’m sort of a noob when it comes to Wordpess; I’ve only recently started building themes and I’ve run into a wall. I’m trying to feature 3 different articles at the top of my site using wpquery and for some reason it’s only displaying one. I’ll include my code below and if anyone can help my figure out what’s wrong I would be very grateful!

Code included in pastebin: http://pastebin.com/1DB7vent

Read More

I’m trying to get a setup similar to this:
[div class=”site_width”]
[ul]
[li]
[a h*ref=”FeaturedLink1″]
[i*mg s*rc=”FeaturedLink1 Featured Image]
[/a]
[label]
[a h*ref=”FeaturedLink1″]
“Featured Link Title”
[/a]
[/label]
[/li]
[Repeat format for two more posts]
[/ul]
[/div]

[]’s & *’s included to prevent se from thinking I’m spamming

Related posts

Leave a Reply

1 comment

  1. After calling get_recent_posts() (or any other loop query), you typically have to run a foreach or while loop to cycle through the posts. So, you’ll need to change this:

        <?php
        $args = array( 'tag' => 'featured', 'posts_per_page' => '3' );
        $recent_posts = wp_get_recent_posts( $args );
        ?>
    
    <!-- Your HTML and WordPress template tags here. -->
    
                <?php wp_reset_query(); ?>
    

    to this:

        <?php
        $args = array( 'tag' => 'featured', 'posts_per_page' => '3' );
                $the_query = new WP_Query( $args );
                //start the WP_Query loop
                while ( $the_query->have_posts() ) : $the_query->the_post();
        ?>
    
    <!-- Your HTML and WordPress template tags here. -->
    
                <?php endwhile; //end the WP_Query loop ?>
                <?php wp_reset_query(); ?>
    

    Note that if you’re ever wondering why a WordPress function isn’t working as expected, you can find that function’s entry in the codex and (usually) see an example of use in practice.
    http://codex.wordpress.org/Function_Reference/wp_get_recent_posts