I poked around and found the “is_page” thing.
What is wrong with this code?
`<div id=”rightcolumn”>
<php if is_page(19) {
<h1>Workshops</h1>
<ul class=”sidemenu”>
<?php wp_get_archives(‘type=postbypost&limit=5’); ?>
</div>’
<div id="rightcolumn">
<?php if( is_page(19) ) { ?>
<h1>Workshops</h1>
<ul class="sidemenu">
<?php wp_get_archives('type=postbypost&limit=5'); ?>
<?php } ?>
</div>
Or to make it a tad more readable for future generations:
<div id="rightcolumn">
<?php if( is_page(19) ) : ?>
<h1>Workshops</h1>
<ul class="sidemenu">
<?php wp_get_archives('type=postbypost&limit=5'); ?>
<?php endif; ?>
</div>
With each of those, I got syntax errors. For the first, it was for the “unexpected } in Line 6,” for the second it was the “endif” that threw things off.
When I remove them, it doesn’t act any differently from what I had before…
…thoughts??
I appreciate your input.
Oops. I am *not* paying attention tonight…
Missed the ?
in the initial opening <?php
tags. Fixed in code above.
This is great, I really appreciate it…
One last thing, and I promise, this is it: I also need it to appear when viewing posts from a particular category. I read up on the conditional tags, and saw the “in_category” tag…I tried to put it into the code a few different ways, but haven’t found the right spot.
If I’m looking to display it also on posts that are in category 5, where do I add that to the code?
The help is muuuch appreciated. Thanks!
It depends on what is meant by “viewing posts from a particular category.”
If you mean when on a category query, you’ll want to look at the is_category() conditional:
http://codex.wordpress.org/Conditional_Tags#A_Category_Page
On a single post page you may need a little tweak, since in_category() is considered more of an ‘in The Loop‘ function and may lack the post object (which it needs) outside it. For this just scope $post to global before using in_category().
A combination of the conditional tests in one if statement for this would look like (assumes category 5):
<?php
global $post;
if( is_page(19) || is_category(5) || (is_single() && in_category(5)) ) :
?>