Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Template Name: Whatever
- */
- // First we need to dump out the contents of the page itself,
- // that's where the standard loop comes into play
- // e.g. If the page has content, (yes/no), while the page has content (if yes then),
- // the_post (loop through to display our page's content).
- if ( have_posts() ) : while ( have_posts() ) : the_post();
- // The page's title
- ?>
- <h2><?php the_title(); ?></h2>
- <?php
- // The page itself's content
- the_content();
- // End the loop
- endwhile;
- // End the if statement
- endif;
- // Let's query for and display some posts now
- // Setup our query arguments
- // Reference: http://codex.wordpress.org/Class_Reference/WP_Query
- $args = array(
- // Number of posts
- 'posts_per_page' => 5,
- // Specific category
- 'category_name' => 'something'
- );
- // Now set a variable to hold your posts loop
- // Call it whatever you like
- $loop = new WP_Query( $args );
- // Run our posts Loop, start with checking if anything was found
- if ( $loop->have_posts() ) :
- // Loop through results if some found
- while ( $loop->have_posts() ) : $loop->the_post();
- ?>
- <h3><?php the_title(); ?></h3>
- <?php // Show the post's excerpt
- the_excerpt();
- // End our posts loop
- endwhile;
- // End our if statement
- endif;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement