0

I called post categories in my main menu using menu section and set them as child menu items now when I click that category menu items I need to make parent menu item active.I know doing this with jQuery for pages in this way

<?php if(is_page( 842 ) || is_page( 846 ) || is_page( 844 ) || is_page( 848 ) || is_page( 'current-tenders' )){?>
<script type="text/javascript">
 jQuery( window ).click(function() {

         jQuery('li.menu-item-28').addClass('tendersactive');
         alert('hi');
     });
</script>
<?php }?>

in is_page( ID ) here ID is page id but how to do in this same way for categories or is there any other way to achieve this?

1

Unfortunately is_category() not worked for me but

if(in_category( 'articles' ))

`in_category()` worked 

Codex reference for in_category().

  • You could have saved yourself time by just commenting to my comment straight away for extra help :-) – Pieter Goosen Mar 12 '15 at 7:29
  • Thanks but really I didn't waste my time I posted this answer today coz someone with the same issue may find this useful. – dh47 Mar 12 '15 at 12:09
  • :-) no problem. For that you get my upvote. Sorry for the crappy comment, wasn't intended to be that way though. Enjoy :-) – Pieter Goosen Mar 12 '15 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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