WordPress.org

Ready to get started?Download WordPress

Forums

What's the opposite of "get"? (11 posts)

  1. jimHere
    Member
    Posted 8 years ago #

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

  2. wyrd33
    Member
    Posted 8 years ago #

    <?php if (!is_search()) { get_calendar(); } ?>

  3. jimHere
    Member
    Posted 8 years ago #

    An exclamation point! Thanks for the tip.

    However, I'm using a custom calendar thing that calls itself "wp_timeline" which is called like:

  4. <h2><?php _e('Calendar'); ?></h2>

      <? wp_timeline(); ?>
  5. Is the exclamation point not working because it's not a real "calendar"

  • alrescha
    Member
    Posted 8 years ago #

    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 } ?>

  • wyrd33
    Member
    Posted 8 years ago #

    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.

  • jimHere
    Member
    Posted 8 years ago #

    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.

  • Jonathan Landrum
    Member
    Posted 8 years ago #

    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.

  • jimHere
    Member
    Posted 8 years ago #

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

  • Jonathan Landrum
    Member
    Posted 8 years ago #

    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.

  • jimHere
    Member
    Posted 8 years ago #

    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!

  • Jonathan Landrum
    Member
    Posted 8 years ago #

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

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags