1

I'm using the following code to add custom taxonomies to my menu in wordpress. I need to make these "sub" items under Products.

Example right now they are showing up:

Photography > Lighting
Photography > Cameras

I need them to show up as

Products > Photography > Lighting
Products > Photography > Cameras

add_filter( 'wp_page_menu', 'custom_page_nav', 90 );
function custom_page_nav( $menu )
{
    $taxonomy = 'catalog';
    $orderby = 'name';
    $show_count = 0; // 1 for yes, 0 for no
    $pad_counts = 1; // 1 for yes, 0 for no
    $hierarchical = true; // 1 for yes, 0 for no
    $title = '';

    $args = array( 'taxonomy' => $taxonomy, 'orderby' => $orderby, 'show_count' => $show_count, 'pad_counts' => $pad_counts,
        'hierarchical' => $hierarchical, 'title_li' => false, 'echo' => false, 'empty' => true, 'hide_empty' => false,
        'depth' => 0 );
    $links .= wp_list_categories( $args );
    //  $links .= wp_list_categories( array( 'title_li' => false, 'echo' => false, 'empty' => true ) );
    $menu = str_replace( '', $links . '', $menu );
    return $menu;
}

Brad
  • 2,237
  • 5
  • 41
  • 69
  • Have you considered using the "menus" feature in version 3.0? You can customize your menu very easily. – rexposadas Jul 25 '10 at 06:25
  • These menu items are created automatically by the plugin. This works fairly well, but there are some problems when there are to many lower level links created. Using the menus features really would not help unless you know how to programmically create the menu items. – Brad Jul 25 '10 at 06:55

1 Answers1

0

function custom_page_nav( $menu ){
    $taxonomy = 'catalog';
    $orderby = 'name';
    $show_count = 0; // 1 for yes, 0 for no
    $pad_counts = 1; // 1 for yes, 0 for no
    $hierarchical = 1; // 1 for yes, 0 for no
    $title = '';

    $args = array( 'taxonomy' => $taxonomy, 'orderby' => $orderby, 'show_count' => $show_count, 'pad_counts' => $pad_counts,
        'hierarchical' => $hierarchical, 'title_li' => false, 'echo' => false, 'empty' => true, 'hide_empty' => true,
        'depth' => 0 );
    $links .= wp_list_categories( $args );
    //  $links .= wp_list_categories( array( 'title_li' => false, 'echo' => false, 'empty' => true ) );
    $menu = str_replace( '', 'Prodcuts '.$links . '', $menu ); 
    //
    return $menu;
}
Brad
  • 2,237
  • 5
  • 41
  • 69