[Plugin: Category Page] Category to appear within page?
-
Hi,
I simply want to have all the content of a category to appear within a page that’s linked to my main nav.
Is there some short code [as in next gen gallery] that I can use in the page: ie – [cat=3]Thanks
-
Please im looking for the this, can any one help !!!
thnx
I would also like to know a better way to do this.
My site has a top navigation bar linking to the Pages, which as defined have the pseudo-static information. One of the Pages (and it’s sub-Pages) is for a certain Group, and by creating a category just for them I know I can make a Blog just for them. I would like their category posts to appear on a page available under their Page navigation.My current work around is to have a link appear on that sub-Page which leads the viewer to the Category page.
Surely there is something more elegant, less work for the viewer?Many thanks,
JAjageo,
I’ve been working on the same problem and today I finally got it. I hope to turn it into a plugin add on for Category Page.
I installed the Category Page plugin and link my pages to the categories (you must do this). Then I created a Page Template. Below is the code for the Page template. The hard part was figuring out the navigation if you don’t want all the post to show up at once.
Keep in mind that I just figured this out today so it’s still rough and some of the formatting code is theme specific but I’m sure it will still work.
Here’s the code:
<?php /* Template Name: Category Page Template */ ?> <?php get_header(); ?> <div id="side-left"> <div id="content"> <?php $current_page = $_GET['posts_page']; $display_num = $_GET['display_num']; ///Enter default number of posts to display at once here (enter -1 to display all): $default_display = 2; //Permalink for page scrolling $base_link = get_permalink(); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="kutu"> <div class="ust"><span></span></div> <div class="post" id="post-<?php the_ID(); ?>"> <h2 class="pagetitle"><?php if ($page_id=="29") echo ""; else the_title(); ?></h2> <div class="entry"> <?php the_content('<p class="serif">Read the rest of this page »</p>'); ?> <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?> </div> </div> <?php endwhile; endif; ?> <?php edit_post_link('Edit this entry.', '<p style="margin:10px;">', '</p>'); ?> <?php $cur_page = $post->ID; $query_catID = $wpdb->get_var("SELECT cat_ID FROM $wpdb->page2cat WHERE page_ID=$cur_page"); ?> <!--For Post Listing--> <?php if ($current_page > "0"){ } else { $current_page = 1; } if ($display_num > "0") { } else { $display_num = 2 ; } // echo 'page=' . $current_page; $offsetnum = ($display_num * ($current_page - 1)); // echo 'offset=' . $offsetnum; $query = 'cat=' . $query_catID . '&showposts=' . $display_num. '&offset=' . $offsetnum; ?> <div class="page-post-listing"> <?php query_posts($query); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="post" id="post-<?php the_ID(); ?>"> <span style="padding-left:5px;" id="post-<?php the_ID(); ?>"><?php the_date('n/j'); ?> - <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></span> <?php echo $this_link; ?> <div class="entry" style="border-bottom:1px dashed #efe7cc;"> <?php the_excerpt(); ?> </div> </div> <?php endwhile; endif; ?> </div> <div class="clear" /> <!--For Post Count--> <?php $post_count = $wpdb->get_var("SELECT count FROM $wpdb->term_taxonomy WHERE term_id=$query_catID"); $aa = $post_count / $display_num ; $bb = intval($aa); if ($aa == $bb) { $num_of_pages = $bb; } else { $num_of_pages = $bb + 1; // echo 'num of pages=' . $num_of_pages; // echo '<br />'; // echo get_permalink(); } if ($num_of_pages > 1){ echo '<div style="color:#d31145; text-align:right; padding:5px;">'; echo '<ul style="border-top: 1px solid #efe7cc;">'; if ($current_page > 1) { echo '<li style="display:inline;"><a href="' . $base_link . '?posts_page=' . ($current_page - 1) . '&display_num=' . $display_num . '"><<</a></li>'; } $pg_count = 0; while ($pg_count < $num_of_pages) { $pg_count += 1; echo '<li style="display:inline;">'; if ($pg_count == $current_page){ echo '<span style="color:#d31145; font-weight:bold;">' . $pg_count . '</span></li>' ; } else { echo '<a href="' . $base_link . '?posts_page=' . ($pg_count) . '&display_num=' . $display_num . '">' . $pg_count . '</a></li>'; } } if ($current_page < $num_of_pages){ echo '<li style="display:inline;"><a href="' . $base_link . '?posts_page=' . ($current_page + 1) . '&display_num=' . $display_num . '">>></a></li>'; } echo '</ul></div>'; } ?> </div> </div></div></div> <?php get_sidebar(); ?> <?php get_footer(); ?>
I’m afraid I bailed out on the idea of finding something elegant and went with a redirect plugin instead, it uses custom fields, so I do have to explain to the end user what they are doing. But after that, simple to implement.
Good luck with your coding. I admire those who can slug through that sort of work.
JAI ended up turning it into a plugin that can be used in conjunction with cat2page. You can read about it and download it here:
- The topic ‘[Plugin: Category Page] Category to appear within page?’ is closed to new replies.