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'd like to know..

How could I change my 3 main categories links, so they call a javascript function?

I'm using Snapshot Theme from WooThemes.

Here's the current state of the website:

http://www.mpn.p.ht/wp_br2/

The categories I'd like to change the links to a javascript function call, are: Masculino, Feminino and Infantil.

They are at a container with class widget.

EDIT:

I´ve changed the jquery.

I've tried to use jquery in index.php:

$(document).ready(function() {

    $(".widget ul li > a").not("ul li ul li>a").attr("href", "javascript:hideMenu();showSubMenu('m-submenu');");
$(".widget ul li+li > a").not("ul li+li ul li>a").attr("href", "javascript:hideMenu();showSubMenu('f-submenu');");
$(".widget ul li+li+li > a").not("ul li+li+li ul li>a").attr("href", "javascript:hideMenu();showSubMenu('i-submenu');");

});

But, it seems that some sub-categories are calling the javascript function. In other words, my .not() it´s not working in some cases.

What could I do?

Thanks.

share|improve this question
    
The Answer is: $(document).ready(function() { $(".widget ul li > a:not(ul li ul li>a, ul li+li ul li>a,ul li+li+li ul li>a )").attr("href", "javascript:hideMenu();showSubMenu('m-submenu')"); $(".widget ul li+li > a:not(ul li ul li>a, ul li+li ul li>a,ul li+li+li ul li>a )").attr("href", "javascript:hideMenu();showSubMenu('f-submenu');"); $(".widget ul li+li+li > a:not(ul li ul li>a, ul li+li ul li>a,ul li+li+li ul li>a )").attr("href", "javascript:hideMenu();showSubMenu('i-submenu');"); }); I must use :not to discard any possible match for every main category. –  Marcelo Noronha May 8 '13 at 18:28
1  
So you found the answer? Next time you should use StackOverflow.com to find jQuery answers. You are using wordpress, but you're problem is jQuery. Have a nice day Brazuca. –  gdaniel May 8 '13 at 18:30
    
I´m not sure. Maybe there´s a wordpress core code better answer. Editing a category.php, category-template.php, or something. That would make life easier. I will have to add the jquery and javascript functions to each page. –  Marcelo Noronha May 8 '13 at 18:43
1  
If you've got your answer, be sure to post and mark as answered. –  ckpepper02 May 8 '13 at 18:45
    
Have to wait some hours until there –  Marcelo Noronha May 8 '13 at 18:50
add comment

1 Answer 1

The Answer is:

$(document).ready(function() {
    $("#f-submenu").hide();
$("#m-submenu").hide();
$("#i-submenu").hide();
$(".widget ul li > a:not(ul li ul li>a, ul li+li ul li>a,ul li+li+li ul li>a     
)").attr("href", "javascript:hideMenu();showSubMenu('m-submenu')");
$(".widget ul li+li > a:not(ul li ul li>a, ul li+li ul li>a,ul li+li+li ul li>a 
)").attr("href", "javascript:hideMenu();showSubMenu('f-submenu');");
$(".widget ul li+li+li > a:not(ul li ul li>a, ul li+li ul li>a,ul li+li+li ul li>a 
)").attr("href", "javascript:hideMenu();showSubMenu('i-submenu');");
});   

It seems I must enter every possible undesirable match in each :not

share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.