dumb wordpress question

Status
Not open for further replies.

bigmanoren

large and in charge
Feb 12, 2008
28
0
0
Really dumb question.

I have a ton of posts, with different categories. I know how to make different pages, but is there anyway to make different pages that pull certain categories, so those pages ONLY show posts from those categories?
 


You could modify your template to link to a category, or find/pay someone to write an addon for you (points to self if you do decent writing and want to exchange the code for written content).
 
Make a page template - then query the posts.

Query by category number:

Code:
<?php 
    query_posts('cat=4'); ?>

    <?php while (have_posts()) : the_post(); ?>
    //do stuff
    <?php endwhile; ?>
Query by category name


Code:
 <?php 
     query_posts('category_name=yourCategoryName'); ?>
 
     <?php while (have_posts()) : the_post(); ?>
     //do stuff
     <?php endwhile; ?>
what your //do stuff might be I don't know - might be this though:

Code:
<div class="post" id="post-<?php the_ID(); ?>">
                <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
                <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>

                <div class="entry">
                    <?php the_content('Read the rest of this entry »'); ?>
                </div>

                <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>
            </div>
 
I do this on one of my sites. Kind of like what radio posted but slightly different.

So say for a category called "cars". Make a copy of page.php, rename it to cars.php and add/replace with this...

Code:
[COLOR=Yellow][I]This goes first[/I][/COLOR]
<?php/*
Template Name: cars.php
*/
?>
[COLOR=Yellow]//[/COLOR]
<?php get_header(); ?>

<?php include(TEMPLATEPATH."/sidebar.php");?>

<?php
if (is_page('[COLOR=Yellow]PAGEID[/COLOR]')) {
query_posts('cat=[COLOR=Yellow]CATID[/COLOR]');
}
?>
    <?php if (have_posts()) : ?>

        <?php while (have_posts()) : the_post(); ?>
//do stuff
<?php endwhile; ?>
Upload cars.php, create a page called "cars" and select cars.phh as your template for that page. That's it!

Not sure if there's much of a difference but it works so I use it. ;)
 
Status
Not open for further replies.