WordPress.org

Ready to get started?Download WordPress

Forums

Adding current-page-ancestor class (2 posts)

  1. farmer_a
    Member
    Posted 1 year ago #

    Hello,

    I selected a post from my News page. My Stories list item was then unclassed and the News list item had the class "current_page_parent". I would have expected the Stories list item to be "current-page-ancestor" and the News page to be "current_page_parent".

    The only way I can think of overcoming this is to do something like:

    if($post->post_parent == '111'){ // if the parent is the News page
    
    add class .current-page-ancestor to list item 3 in the #access menu
    
    }

    But I don't know enough php to do the code, or where to put it but I know the #access menu is in header.php.

    Regards,

    Andy

  2. farmer_a
    Member
    Posted 1 year ago #

    I tried this, but it didn't work:

    if($post->post_parent == '111'){ // if the parent is the News page
    
    $('#access.li.menu-item-192').addClass('current-page-ancestor');
    
    }

    Thanks in advance for any help,

    Thanks,

    Andy

Topic Closed

This topic has been closed to new replies.

About this Topic