WordPress.org

Ready to get started?Download WordPress

Forums

twentyten menu - remove sub menus (13 posts)

  1. neologan
    Member
    Posted 2 years ago #

    I'm using a child theme, i want to remove the drop down menus from the main menu as i don't need them. Any ideas?

    I haven't found a solution yet. Any help?

  2. If you mean you want to not display the nav bar, try CSS in your child theme's style.css file. The Firefox extension Firebug is really useful for identifying CSS like that.

    #access {
       display: none;
    }

    But somehow I suspect that's not exactly what you meant. ;)

  3. neologan
    Member
    Posted 2 years ago #

    i already new I could try something like this, but was after a function type solution if possible

  4. I guess what I really meant was "Can you explain in more detail what you want to do?"

    If it's just hide the nav bar like that, then that's an easy solution and your child them already has it's own style.css file for things like that.

    But can you provide a link to demonstrate what you mean?

    I think you mean multilevel menus (which can be customized using http://your-wordpress-url-here/wp-admin/nav-menus.php) but I've not had enough coffee yet to be sure.

  5. neologan
    Member
    Posted 2 years ago #

    Sorry, i'll try to explain by using a css example.

    #access ul li:hover > ul {
    	display: block;
    }

    to "none" removes the submenus (drop down menus. This is what i want to do, i just thought there might be some code to remove them. Are you saying css is the best method (not a hack?). If so i guess i could use it. I suppose having them hidden means i still get better SEO to those links.

  6. Are you saying css is the best method (not a hack?). If so i guess i could use it.

    Generally speaking and in my opinion: yes, CSS modifications are easier to support than modifying code via functions.php in a child theme.

    Rather than working out how to prevent those submenus in PHP, it's best to just hide them via a few lines of CSS. Simpler can be better sometimes.

  7. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    general philosophy:
    CSS adaptations can be faster/easier to implement, however, avoiding the rendering of some unwanted content already on the server, and thereby avoiding extra bandwidth to download the content to the broswer, is of course more desirable (in my personal opinion) (also keeps people from checking the hidden stuff by viewing the source code in the broswer).
    is a bit like modern medicine - choice between hiding the symptoms or curing the cause.

    to answer the question of this topic:
    if you don't use the 'appearance - menus' custom menu option, then the theme will fall back to use 'wp_page_menu()' which you can influence with a filter in functions.php of your child theme:

    try for example:

    function twentyten_child_page_menu_args( $args ) {
    	$args['depth'] = 1;
    	return $args;
    }
    add_filter( 'wp_page_menu_args', 'twentyten_child_page_menu_args' );

    weird and wonderful - the 'depth' parameter is not mentioned in the respective codex chapter http://codex.wordpress.org/Function_Reference/wp_page_menu
    , but did work anyway in my test.

  8. Much thanks. Hands down, that's a much better reply and directly addresses the problem. ;)

  9. neologan
    Member
    Posted 2 years ago #

    thanks for that, sadly I am using the appearance - menus method. Is there a similar method when using these?

    There are reasons why I need those submenus (styling properties when on certain pages linked to those submenus).

  10. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    general,
    wp_nav_menu() also has the 'depth' parameter;
    http://codex.wordpress.org/Function_Reference/wp_nav_menu

    I need those submenus (styling properties when on certain pages linked to those submenus).

    does this mean that you need to keep the dropdown for selective pages?

  11. neologan
    Member
    Posted 2 years ago #

    it's actually because of how categories placed in a menu can create parent styles.

    For example, if I'm on a post that was filed under "apples", and that category is a subcat in the menu under "fruit", it will allow me to style that fruit menu button as highlighted. Hope that makes sense, if not I can give you a link instead.

    If will try the above and see if it works, thanks!

  12. neologan
    Member
    Posted 2 years ago #

    i think i may need some more info on your example. My child theme is called altesc (i have a feeling that may be important?)

    function twentyten_child_page_menu_args( $args ) {
    	$args['depth'] = 1;
    	return $args;
    }
    add_filter( 'wp_page_menu_args', 'twentyten_child_page_menu_args' );

    not really sure how to tweak this for my theme.

  13. neologan
    Member
    Posted 2 years ago #

    nevermind, i forgot to add _args when I added wp_nav_menu.

    function twentyten_child_page_menu_args( $args ) {
    	$args['depth'] = 1;
    	return $args;
    }
    add_filter( 'wp_nav_menu_args', 'twentyten_child_page_menu_args' );

    thanks again to both of you.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags