1) Create a page on theme folder name "custom2.php"
2) Paste following code into custom2.php file
<?php
/*
Template Name: Custom Query category page.
*/
?>
<?php get_header(); ?>
<h3>Recent Articles</h3><br />
<ul>
<?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('showposts=2&cat=1'.'&paged='.$paged);
?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
<div class="navigation">
<div class="alignleft"><?php previous_posts_link('« Previous') ?></div>
<div class="alignright"><?php next_posts_link('Next »') ?></div>
</div>
<?php $wp_query = null; $wp_query = $temp;?>
<?php get_footer(); ?>
3) Create one page on backend side and select template "Custom Query category page".
That's it.
No comments:
Post a Comment
Please mention your comments.......