• Resolved andregois

    (@andregois)


    Hello,

    I have my wp_list_pages inside a scrollable div.

    Is there any way I can make the div scroll down to the current_page_item at page load? (so the current page link is visible to the user).

    Thank you for your help!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Javascript, but there might be other ways to do it. An URL would help.

    Thread Starter andregois

    (@andregois)

    Thank you. I will try that.

    Thread Starter andregois

    (@andregois)

    From what I understand “scrollIntoView” needs an objectID as target.
    But wp_list_pages generates “current_page_item” as a Class.

    Is there anyway arround this?

    Thank you all.

    Thread Starter andregois

    (@andregois)

    anyone?

    Thread Starter andregois

    (@andregois)

    I figured out what I want to to do is to add an anchor to the link (on the list generated by “wp_list_pages”) that corresponds to the the current page (current_page_item).

    Does anyone know how to achieve this?

    Thanks a lot!

    Thread Starter andregois

    (@andregois)

    I got it!

    In case someone has the same need, you can edit classes.php in wp-includes folder.

    add a new variable (ex. $anchorname) to:

    if ( $page->ID == $current_page ){
    $css_class[] = 'current_page_item';
    $anchorname = 'link_name';}

    then add it to $output below like this:

    $output .= $indent . '<li class="' . $css_class . '"><a>ID) . '" title="' . esc_attr(apply_filters('the_title', $page->post_title)) . '" name="' . $anchorname . '">' . $link_before . apply_filters('the_title', $page->post_title) . $link_after . '</a>';

    if you check your output your link now has a name=”link_name” 🙂
    Hope this helps someone else.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘jump to current_page_item’ is closed to new replies.