WordPress.org

Ready to get started?Download WordPress

Ideas

add filter hook to modify css class for Walker_Page::start_el() function

  1. almostdaniel
    Member

    When using wp_list_pages() to display the page hierarchy for navigation purposes, it would be useful to be able to modify the css placed into the output. For example, I want to designate which pages have children by styling a right-hand arrow only on those pages. This requires a class (e.g., "parent" or "ancestor") to differentiate from Pages that have no children.

    This is already done in a way for the current_page (current_page_ancestor, current_page_parent). And we can obviously figure out child pages with CSS (ul li ul li). But going the other direction is difficult.

    Instead of requesting a specific code change related to that case, perhaps a new filter hook placed in the middle of the start_el() function would deal with other cases.

    If there was a filter hook somewhere between lines 1175 and 1193 in classes.php that examined the args and css_class arrays, then I could check the state of a page at that point (e.g., $args['has_children']) and modify the css_class array appropriately.

    Posted: 5 years ago #
  2. Aaron Jorbin
    Member

    +1

    Posted: 5 years ago #
  3. Andy Macaulay-Brook
    Member

    12345

    I'm often hitting cases where a filter for the elements in a list would be useful. Writing my own walkers is the only way to do this at the moment.

    Posted: 4 years ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    7 Votes
  • Status

    This idea is under consideration