• I’m trying to make it so that on the search results page, the calendar (which is usually on every page) is not displayed, while the Archives list (which is usually not on any page) IS displayed.

    So, I have:
    <?php if ( is_search() ) { get_archives(); } ?>
    in my side bar to show the archives list, but what do I use to hide the calendar here?

    <?php if ( is_search() ) { hide_calendar(); } ?>
    would be nice…

Viewing 10 replies - 1 through 10 (of 10 total)
  • <?php if (!is_search()) { get_calendar(); } ?>

    Thread Starter jimhere

    (@jimhere)

    An exclamation point! Thanks for the tip.

    However, I’m using a custom calendar thing that calls itself “wp_timeline” which is called like:

    • <h2><?php _e(‘Calendar’); ?></h2>
      <? wp_timeline(); ?>

    Is the exclamation point not working because it’s not a real “calendar”

    You’re thinking about this the wrong way. It’s not about “hiding” the calendar, it’s about “not displaying it”. In other words, “display it if it’s not a search page”.

    <?php if (!is_search()) { ?>
    <h2><?php _e('Calendar'); ?></h2>
    <?php wp_timeline(); ?>
    <?php } ?>

    The exclamation point means “not”. Basically what if (!is_search()) is saying is: if NOT is_search, then do this. So in other words, only show the calendar if the page is not a search result.

    Thread Starter jimhere

    (@jimhere)

    Well, this works great, thanks for the clear up.

    As I originally said, instead of the Calendar I’m having Archives display on the search results page:
    <?php if ( is_search() ) { get_archives(); } ?>

    But since it only appears here, how can I style it in sidebar.php so it’s not visible anywhere else? With my modifications, my list styles seem to be gone on this page.

    I tried to use the suggested formatting, except for the ! (because it Should show here):

    <?php if ( is_search() ) { get_archives(); } ?>
    {li}
    <h2><?php _e(‘Archives’); ?></h2>
    {ul}
    <?php wp_get_archives(); ?>
    <?php } ?>
    {/ul}
    {/li}

    but this just renders the Whole sidebar empty.

    Try this:

    <?php if ( is_search() ) { ?>
    <li>
    <h2><?php _e('Archives'); ?></h2>
    <ul>
    <?php wp_get_archives(); ?>
    </ul>
    </li>
    <?php } ?>

    Edit: You have to keep your tags in a mirror order. I.e. <p><strong></p></strong> will return an HTML error, and what you typed will return a PHP error. Unfortunately, an HTML error may only render your page sort of funny-looking. A PHP error won’t render anything. Hence, your sidebar doesn’t show.

    Thread Starter jimhere

    (@jimhere)

    Mirror order? OK, I pasted your suggestion into my sidebar file. The info shows up, but the list style is still odd. Do you think an ‘html error” is why bullet discs are showing up on the Search page’s sidebar lists?

    go here
    http://jimsite.com/blogWordpress/
    and see the side bar look. Then do a search for gibberish. The Search page’s lists are nutty compared to the main page…

    What I meant by mirroring the order of your tags is this: tag 1, tag 2, tag 3, -text- end tag 3, end tag 2, end tag 1.

    In your sidebar I noticed two things (the first may be nothing serious):

    • Search block is within <p> tags; probably should switch to <div>
    • Before catagories section:

      <li>
      </ul>
      </li>

    Edit: I didn’t notice any stray bullets in IE or Firefox; both show up sans list style.

    Thread Starter jimhere

    (@jimhere)

    First of all, thanks for your help, because it works.

    I stared and stared at my pairs of opening and closing list tags but couldn’t find anything wrong.

    Then I noticed that the “<?php } ?>”s for finishing the blocks were inconsistent. I placed them each after their /ul’s and now it works!

    Kool-Aide! Glad it was something simple and easy to fix.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘What’s the opposite of “get”?’ is closed to new replies.