WordPress.org

Ready to get started?Download WordPress

Forums

Sidebars (help!) (7 posts)

  1. driplabcom
    Member
    Posted 6 years ago #

    Hey all.

    I have a three column "Marketplace" theme employed on CreatingYourJourney.com.

    Here's what I need: the far right column to be empty on every page except for one (Workshops).

    Is that possible?

    A point in the right direction would be great.

    THANKS!

  2. driplabcom
    Member
    Posted 6 years ago #

    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>'

  3. Kafkaesqui

    Posted 6 years ago #

    <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>
  4. driplabcom
    Member
    Posted 6 years ago #

    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.

  5. Kafkaesqui

    Posted 6 years ago #

    Oops. I am *not* paying attention tonight...

    Missed the ? in the initial opening <?php tags. Fixed in code above.

  6. driplabcom
    Member
    Posted 6 years ago #

    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!

  7. Kafkaesqui

    Posted 6 years ago #

    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)) ) :
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic