WordPress.org

Forums

[resolved] Page Links To redirect page not assigned current_page_item (11 posts)

  1. danbranigan
    Member
    Posted 3 years ago #

    I’m using the 2.1 version of this plugin with WordPress 2.8.4 but the

  2. that contains the redirected page link in my menu isn’t picking up the “current_page_item” class. I’m pretty sure that in the “versions” list for this plugin above the author says that “If you link to an internal WordPress page, like a category, the menu item will get the current_item CSS class when you’re on that page”.
    Any ideas? Cheers, Dan.
  3. http://wordpress.org/extend/plugins/page-links-to/

  • maorb
    Member
    Posted 3 years ago #

    I'm also having this problem, just was about to submit a ticket.
    Will be very happy for ideas how to solve this, or to other plugin that does the same job and don't have this bug.

    Thanks

  • Gleasonator
    Member
    Posted 3 years ago #

    Just downloaded and installed this... I noticed this as well. I'm bumping this up since it's also something that I'd like fixed as well.

    Thanks,
    Alex

  • ZackAjmal
    Member
    Posted 3 years ago #

    I have the same issue.

  • ZackAjmal
    Member
    Posted 3 years ago #

    I have figured out the problem.

    In page-links-to.php, lines 178-181 are:

    if ( $highlight ) {
    	                $pages = str_replace( ' class="page_item current_page_item"', ' class="page_item"', $pages );
    	                $pages = str_replace( '<li class="page_item"><a href="' . $current_page . '"', '<li class="page_item current_page_item"><a href="' . $current_page . '"', $pages );
    	        }

    Replace them by:

    if ( $highlight ) {
                    $pages = preg_replace( '/ class="page_item page-item-(\d+) current_page_item"/', ' class="page_item page-item-$1"', $pages );
                    $pattern = '|<li class="page_item page-item-(\d+)"><a href="' . $current_page . '"|';
                    $replacement = '<li class="page_item page-item-$1 current_page_item"><a href="' . $current_page . '"';
                    $pages = preg_replace( $pattern, $replacement, $pages );
            }
  • nejin
    Member
    Posted 3 years ago #

    I had a similar problem, but solved it by applying the current_page_item to the child.

    ul li.current_page_item a (so adding the child, in this case 'a' was the solution)

  • Harv27
    Member
    Posted 3 years ago #

    I tried ZackAjmal's fix and it didn't work. Nor did nejin's, didn't really understand it.
    Any ideas?
    OR is there an alternative plugin?
    thanks!

  • Mark Jaquith
    WordPress Lead Dev
    Posted 3 years ago #

    Do you still experience this with version 2.2?

  • Mark Jaquith
    WordPress Lead Dev
    Posted 3 years ago #

    Version 2.3 fixes this issue. My test case was assigning a category URL. It got the correct highlighting class. I just pushed 2.3 out, and it should be available in 15-30 minutes.

  • bradtke
    Member
    Posted 3 years ago #

    Proper highlighting is still an issue. Using version 2.3 and still having issues. Tried applying to multiple themes and get the same result. The example I'm using is when redirecting to a category. The current_page_item is never replaced properly.

  • laurenod
    Member
    Posted 3 years ago #

    Using version 2.3 I was redirecting to a child post from the parent and the current_page_item (active class) was not working.

    I fixed the problem by commenting out this line (186):

    if ( $highlight ) {
    //$pages = preg_replace( '| class="([^"]+)current_page_item"|', ' class="$1"', $pages ); // Kill default highlighting
    $pages = preg_replace( '|<li class="([^"]+)"><a href="' . $current_page . '"', $pages );
    }

    At the moment I haven't noticed any side effects of this fix.

  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags