wordpress snippets part 2

page.php code

        <?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
  <h2><?php the_title(); ?></h2>
    <?php the_content(); ?>
    <div style="clear:both"></div>
<?php endwhile; ?>
<?php else : ?>
<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
<?php get_search_form(); ?>
<?php endif; ?>

get post from catagory

<?php query_posts('category_name=NAME-HERE&posts_per_page=1'); ?>
 <?php while (have_posts()) : the_post(); ?>
<!-- Content Here -->
<?php endwhile;?>


catagory.php snippet

<? /*Begin Content area Query*/ ?>
<?php if (have_posts()) : ?>
  <?php while (have_posts()) : the_post(); ?>
      <h2 class="CatTitle"><?php the_title(); ?></h2>
    <div class="cat-excerpt-content">
        <?php the_excerpt(); ?>
    </div>
   <?php endwhile; ?>
   <div class="navigation">
  <div class="alignleft">
    <?php next_posts_link('&laquo; Older Entries') ?>
  </div>
  <div class="alignright">
    <?php previous_posts_link('Newer Entries &raquo;') ?>
  </div>
</div>
 <?php else : ?>
 <h2 class="center">Not Found</h2>
 <p class="center">Sorry, but you are looking for something that isn't here.</p>
 <?php get_search_form(); ?>
<?php endif; wp_reset_query(); ?>
<? /*End Content area Query*/ ?>

No comments:

Post a Comment