Advertisement
Guest User

Untitled

a guest
Dec 9th, 2010
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. <?php
  2. /**
  3. * Template Name: Page of Posts
  4. *
  5. * A custom page template for article section.
  6. *
  7. * The "Template Name:" bit above allows this to be selectable
  8. * from a dropdown menu on the edit page screen.
  9. *
  10. * @package WordPress
  11. * @subpackage Twenty_Ten
  12. * @since Twenty Ten 1.0
  13. */
  14.  
  15. get_header(posts); ?>
  16.  
  17. <div id="container">
  18. <div id="content" role="main">
  19.  
  20. <?php
  21. if (is_page() ) {
  22. $category = get_post_meta($posts[0]->ID, 'category', true);
  23. }
  24. if ($category) {
  25. $cat = get_cat_ID($category);
  26. $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  27. $post_per_page = 0; // -1 shows all posts
  28. $do_not_show_stickies = 1; // 0 to show stickies
  29.  
  30. $args=array(
  31.  
  32. 'category__in' => array($cat),
  33. 'showposts' => $showposts,
  34.  
  35. 'caller_get_posts' => $do_not_show_stickies
  36.  
  37. );
  38.  
  39. $my_query = new WP_Query($args);
  40.  
  41. ?>
  42.  
  43.  
  44.  
  45. <?php if( $my_query->have_posts() ) : ?>
  46.  
  47. <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
  48.  
  49. <?php $count++; ?>
  50. <!-- This is where you tell how many posts to show excerpts -->
  51. <?php if ($count <= 3) : ?>
  52.  
  53. <h2 class="entry-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
  54.  
  55. <div class="entry-meta">
  56. <span class="meta-prep meta-prep-author">Posted on</span>
  57. <span class="entry-date">
  58. <?php the_time('F jS, Y') ?>
  59. </span>
  60. <span class="meta-sep">by</span>
  61. <span class="author vcard"><?php the_author_posts_link() ?></span>
  62. </div>
  63.  
  64.  
  65. <div class="entry-content">
  66. <?php
  67. global $more; // Declare global $more (before the loop).
  68. $more = 0; // Set (inside the loop) to display content above the more tag.
  69. the_content("Continue Reading...");
  70. ?>
  71. </div>
  72.  
  73.  
  74. <?php else : ?>
  75.  
  76.  
  77.  
  78. <h2 class="entry-title" style="margin-top: 10px; font-size: 16px;"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
  79.  
  80.  
  81.  
  82.  
  83.  
  84. <?php
  85.  
  86. //necessary to show the tags
  87.  
  88. global $wp_query;
  89.  
  90. $wp_query->in_the_loop = true;
  91.  
  92. ?>
  93.  
  94.  
  95.  
  96.  
  97. <?php endif; ?>
  98.  
  99.  
  100.  
  101. <?php endwhile; ?>
  102.  
  103.  
  104.  
  105. <?php else : ?>
  106.  
  107.  
  108.  
  109. <h3 class="center">Not Found</h3>
  110.  
  111. <p class="center">Sorry, but you are looking for something that isn't here.</p>
  112.  
  113. <?php get_search_form(); ?>
  114.  
  115.  
  116.  
  117. <?php endif;
  118.  
  119.  
  120. } // if ($category)
  121. ?>
  122.  
  123. </div><!-- #content -->
  124. </div><!-- #container -->
  125.  
  126. <?php get_sidebar('posts'); ?>
  127. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement