Forums

How to add drop-down menu for links? (11 posts)

  1. grallaj
    Member
    Posted 2 years ago #

    Can you help me with the code for this?

    On my blog, I have 3 categories of links: Pictures, RSS Feed, and Videos. Right now, in the sidebar, I list all of these using wp_list_bookmarks('orderby=id'). What I would like to do is put the Pictures in a drop-down menu to select, and then list the RSS Feed and Videos just like I am now...

    Can anyone help me out?

    Thanks.

  2. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    There is no way (that I know of) to create a dropdown menu using wp_list_bookmarks.

  3. grallaj
    Member
    Posted 2 years ago #

    Could it work somehow with get_bookmarks? I tried, but to no avail...

  4. Shane G
    Member
    Posted 2 years ago #

  5. grallaj
    Member
    Posted 2 years ago #

    None of those were working for me... Maybe I just don't know enough code...

    In my sidebar - the following code works for my drop-down archive:

    <li><h2>Archives</h2>
    				<ul>
    <select name=\"archive-dropdown\" onChange='document.location.href=this.options[this.selectedIndex].value;'>
      <option value=\"\"><?php echo attribute_escape(__('Select Month')); ?></option>
      <?php wp_get_archives('type=monthly&format=option&show_post_count=1'); ?> </select>
    				</ul>
    			</li>

    So - I am a little confused as to why the following doesn't work for a Pictures drop-down box a little below that in the sidebar:

    <li><h2>Pictures</h2>
    				<ul>
    <select name=\"picture-dropdown\" onChange='document.location.href=this.options[this.selectedIndex].value;'>
      <option value=\"\"><?php echo attribute_escape(__('Select Pictures')); ?></option>
      <?php get_bookmarks('category_name=Pictures'); ?> </select>
    				</ul>
    			</li>
  6. grallaj
    Member
    Posted 2 years ago #

    Any thoughts?

  7. grallaj
    Member
    Posted 2 years ago #

    I guess it can't be done...

  8. viceng
    Member
    Posted 2 years ago #

    are you talking about putting pictures in the main nav bar?

  9. grallaj
    Member
    Posted 2 years ago #

    A drop-down menu of my picture links in the sidebar...

  10. grallaj
    Member
    Posted 2 years ago #

    bump for anyone who might have an idea...

  11. Mark / t31os
    Moderator
    Posted 2 years ago #

    <?php
    $test = wp_list_bookmarks('echo=0&title_li=&categorize=0');
    $test = str_replace('<li','<option',$test);
    $test = str_replace('/li>','/option>',$test);
    echo $test;
    ?>

    Would work.... however i've found that WordPress is removing any option tags i plonk in the template file..

    You can verify that wordpress does this by replacing "option" in the above code to anything else.. "opt10n" for example would work, but is no good since it's totally invalid code.

Topic Closed

This topic has been closed to new replies.

About this Topic