Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
Why do you need to add a class for parent menu items?
What are you trying to do, add some CSS to only sub menu <ul>
elements?
Thread Starter
djf88
(@djf88)
No, I can see that sub menu
elements have their own CSS class.
I simply want to add a dropdown arrow as the background image for all ‘parent menu items’.
Thanks
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
Please can you wrap HTML elements using the (code) button – in this forum post
I added this to my functions.php file but it just kills my site and I get a blank screen.
possibly a syntax error due to a wrong location; I just checked the suggested code, and it is working without error.
make sure to add the code at the end of functions.php just before the ?>
(or if this is not there, then just add the new code at the bottom of functions.php)
if you paste the full code of functions.php into a http://pastebin.com/ and post the link to it here ( http://codex.wordpress.org/Forum_Welcome#Posting_Code ) someone might be able to show where to add the filter safely.
Thread Starter
djf88
(@djf88)
Hi alchymyth, thankyou for your help,
I’m not sure that is what I’m doing wrong but I’m sure you’re in a better position to say, so here we go: functions.php
Thanks
I can’t find anything wrong with that functions.php – is it still causing a blank screen?
Thread Starter
djf88
(@djf88)
Ah, I was worried you might say that.
Yep, still a blank screen, tried it in Chrome instead of Firefox and it says ‘Internal Server Error’..
Am I beyond helping now?
Thread Starter
djf88
(@djf88)
I’m not sure what you did but you’re a genius, thank you very much!
not sure what you did
the Codex example was using an ‘anonymous’ function in the filter; I transformed this into ordinary functions.
from:
http://codex.wordpress.org/Function_Reference/add_filter#Notes
You can also pass an an anonymous function as a callback. For example:
<?php add_filter('the_title', function($title) { return '<b>'. $title. '</b>';}) ?>
Beware
Anonymous functions [1] were introduced in PHP 5.3.0. Check Hosting WordPress requirements and double check your PHP version before using them.
The solution here: http://codex.wordpress.org/Function_Reference/wp_nav_menu#How_to_add_a_parent_class_for_menu_item works like a charm. probably there is something missing in your function.php or it conflicts with another function somewhere else. I tried it on _S framework and it’s fine.