WordPress.org

Support

Support » How-To and Troubleshooting » Wildcard for child categories in Dynamic Menu

Wildcard for child categories in Dynamic Menu

  • I need a wildcard for describing the subcategories, so that if the user browses a page in a subcategory of the main-category, main-category is highlighted in the menu:
    something like this:

    elseif ( is_page(‘main-category/*’) ) { $current = ‘#nav_categories’; }

    I tried to replace the is_page function declaration with this:

    function is_page ($page = ”) {
    global $wp_query;

    if ( !$wp_query->is_page )
    return false;

    if ( empty($page) )
    return true;

    $page_obj = $wp_query->get_queried_object();

    if ( strpos($page,$page_obj->ID)===true )
    return true;
    elseif (strpos($page,$page_obj->post_title)===true )
    return true;
    else if (strpos($page,$page_obj->post_name)===true )
    return true;

    return false;
    }

    it did not work though!
    Any idea?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Wildcard for child categories in Dynamic Menu’ is closed to new replies.