Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using this plugin called buddypress links and in it's link directory page the user can sort through the links by category from a drop down list(screenshot).What I need is seperate links for each category not a drop down list and after some searching I tried to follow a tutorial to pre-select an item from a drop down list using JavaScript.BUT NOTHING HAPPENS.

Here's the code from the directory page which generates the category select drop down list

<?php bp_links_dtheme_link_category_filter_options_list() ?>

which i traced to

function bp_links_dtheme_link_category_filter_options_list() { ?>
    <li id="links-category-select" class="last">
        <?php _e( 'Category:', 'buddypress-links' ) ?>
        <select id="links-category-filter">
            <option value="-1"><?php _e( 'All', 'buddypress' ) ?></option>
            <?php bp_links_category_select_options() ?>
            <?php do_action( 'bp_links_category_filter_options' ) ?>
        </select>
        <?php wp_register_script( 'myjavapage', 'newser.js' ); ?>
        <?php wp_enqueue_script( 'myjavapage', 'newser.js' ); ?>
        <?php
function my_scripts_loader() {
wp_enqueue_script( 'myjavapage', 'newser.js', false );
}
add_action( 'wp_enqueue_scripts', 'my_scripts_loader' );
?>
    </li> <?php
}

And the javascipt file

<script>
function setSelectedIndex(s, v) {
for ( var i = 0; i < s.options.length; i++ ) {
if ( s.options[i].text == v ) {
s.options[i].selected = true;
return;
}
}
}
setSelectedIndex(document.getElementById('links-category-filter'),"News");
</script>

As you've probably figured out by now, I'm 70% stupid and 30% dumb and this code is from tutorials that I barely understand.So please help me out before I start loosing my hair.

BTW, any other solution that will result in being able to create separate links to each category will work perfectly fine.

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.