1. That’s a bit complicated. I don’t have an out of the box solution for that.
2. See Category_Templates; Template_Hierarchy and other useful articles in WP’s online manual the Codex.
Ok. That template stuff confused me completely but I know that for my second query it is all associated with the header.php file (which refers to the kubrick images), so I’m guessing that if I created a duplicate header file (called header2.php for example) that pointed to the other, altered pictures, I’d then have to do something someplace else to tell that when viewing the ‘Press’ category to use the header2.php file instead of the normal one??? Or something. No?
You have to understand the “temnplate stuff” before you can achieve what you described earlier. There is no shortcut 🙂
And for category templates, see this thread:
http://wordpress.org/support/topic/30653?replies=16
Ok. Still somewhat confused, but following that page as best I can I have created a category.php file that, at present, contains duplicated code from the page.php file, as follows;
<?php get_header(); ?>
<div id=”content” class=”narrowcolumn”>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class=”post” id=”post-<?php the_ID(); ?>”>
<h2><?php the_title(); ?></h2>
<div class=”entrytext”>
<?php the_content(‘<p class=”serif”>Read the rest of this page »’); ?>
<?php link_pages(‘Pages: ‘, ”, ‘number’); ?>
</div>
</div>
<?php endwhile; endif; ?>
<?php edit_post_link(‘Edit this entry.’, ”, ”); ?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
I understand that this now has to be edited to include something like <?php if ( is_category() ) : ?> somewhere to make it only work on the category pages (Press is cat 3 on my site I believe). And also I want it to use the other header2.php file I made don’t I? Or do I somehow include that code in the category.php file?
In my head this seems pretty simple; when in this category, use these images instead of these ones. I am however quite quite tired and feeling pretty moronic at the mo. 😉
Woo! I figured it out don’t worry! Thanks for all your help.
Just for those that will come to read it later:
1. The best thing for creating a category.php
template is to start with the archive.php
2. You don’t need any “if category”-stuff: WP is smarter than that and recognizes the template. see Template_Hierarchy.
3. You can have as many category templates as many categories you have: category-1.php, category-2.php
etc.
Hiding Posts from a category in the archive view:
1. create a file archive.php
2. define the style of the archive page and put the loop also in the file. before the loop you need to write the following:
if(is_archive()){$wp_query->set('cat','-ID'); query_posts(''); }
3. When you use the code above, you still can use the prev/next function.
4. Want to exclude more than one category from archive –> define a category in which you put all the categories, you don’t want to be shown.
greets,
pati
ps: works also with is_home() 😉
I can’t seem to make this work. I want to omit one category from my archives – ID 19 – so I used the following code on a template page names archives.php:
<?php if(is_archive()){$wp_query->set('cat','-19'); query_posts(''); } ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<ul><?php get_archives('postbypost','','custom','<li>','</li>'); ?></ul>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
What have I done wrong?
archive.php – no S at the end!