Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Template Name: OneCategory
- ** Create a Page and assign this template. Create a Custom Field
- ** named 'category-to-show' and assign it the name of the category.
- **
- ** Any sticky posts in the category will be shown before others.
- **
- */
- ?>
- <?php global $more; $more = 0;?>
- <?php get_header(); ?>
- <div id="content"><!-- file:OneCategory.php -->
- <div class="post";?><h2><?php the_title(); ?></h2></div>
- <?php $this_cat=get_post_meta($post->ID,'category-to-show',TRUE);
- if ($this_cat != "") {
- $paged = get_query_var('paged');
- $stickies = get_option('sticky_posts');
- $args = array( 'category_name' => $this_cat, 'paged' => $paged,);
- if (!$paged) { // Only show stickies on first page
- $myquery_hold = $wp_query;
- $args['post__in'] = $stickies;
- query_posts($args);
- $found_posts = 0; // Use this to not show warning if only stickies
- if (have_posts()) {++$found_posts; bmc_show_category($nav=false);};
- unset($args['post__in']);
- $wp_query = $myquery_hold;
- }
- $args['post__not_in'] = $stickies;
- query_posts($args);
- if (have_posts()) {
- bmc_show_category($nav=true);
- } elseif (!$found_posts) {
- echo "<h4></h4>There are no posts in this category $this_cat<h4></h4>";
- }
- } else {
- echo "<h4></h4>This page is missing the Custom Field 'category-to-show'".
- "whose value is the name of the category to be shown." .
- "<br />Please have the page corrected.";
- } ?>
- </div><!-- content -->
- <?php get_footer(); ?>
- <?php function bmc_show_category ($nav = true) {
- global $mam_global_post_link_args;
- while (have_posts()) : the_post(); ?>
- <div class="post" id="post-<?php the_ID(); ?>">
- <hr /><h2><a href="<?php echo htmlentities(add_query_arg('stayincat',get_query_var('cat'),get_permalink())) ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
- <?php if (!is_sticky() && (is_category('ForSale') || is_category('WantToBuy'))) {
- echo '<p>Ad placed on ';the_time('F jS, Y');echo '</p>';
- } ?>
- <div class="entry">
- <?php $mam_global_post_link_args =
- array('stayincat' => get_query_var('cat'));
- ?>
- <?php the_content(' (more...)'); ?>
- </div>
- <?php if ($nav) { ?>
- <p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />');
- ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>
- <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
- </p>
- <?php } ?>
- <?php echo "<a class=\"pageprevlink\" href=\"";
- the_permalink();
- echo "\"> Comment or Reply </a>";
- ?>
- <?php $mam_global_post_link_args = ''; ?>
- </div>
- <?php endwhile; ?>
- <?php if ($nav) { ?>
- <div class="navigation">
- <div class="alignleft"><?php next_posts_link('« Older Entries «') ?></div>
- <div class="alignright"><?php previous_posts_link('» Newer Entries »') ?></div>
- </div>
- <?php } // End of if $nav ?>
- <?php } // End of Function bmc_show_category ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement