WordPress.org

Ready to get started?Download WordPress

Forums

Wildcard for child categories in Dynamic Menu (2 posts)

  1. Darkt
    Member
    Posted 7 years ago #

    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?

  2. Darkt
    Member
    Posted 7 years ago #

    anyone?

Topic Closed

This topic has been closed to new replies.

About this Topic