Community @ The Turning Gate

Support community for TTG plugins and products.

NOTICE

The Turning Gate's Community has moved to a new home, at https://discourse.theturninggate.net.

This forum is now closed, and exists here as a read-only archive.

  • New user registrations are disabled.
  • Users cannot create new topics.
  • Users cannot reply to existing topics.

You are not logged in.

#1 2019-11-28 21:53:11

volvoxturbo
Member
From: Barcelona - Frankfurt - Rome
Registered: 2012-11-12
Posts: 247
Website

Highlight the current page menu item in WP-Theme

Hi all,

highlighting the current page menu item is not working for me in the WP-Theme. Why is that?

I use the phplugins script:

// Add class "current_page_item" to menu item for the current page;
// You can style this as you like, for example, to highlight the current page menu item.
function scripts() {
echo <<<SCRIPT
    <script>
    $("ul.menu a[href='" + window.location.pathname + "']")
        .parentsUntil('.menu', 'li')
        .addClass("current_page_item")
        ;
    </script>
SCRIPT;
    return false;
} // END /**/

with the CSS:

a.current_page_item, .current_page_item a {
    text-decoration: underline !important;
    color: #ff8000 !important;
   
}

It works perfect with Backlight but has no effect on the WP Site

Any suggestions???

Thanks in advance.

Best regards,
Oliver

Offline

#2 2019-11-28 23:46:47

rod barbee
Moderator
From: Port Ludlow, WA USA
Registered: 2012-09-24
Posts: 17,830
Website

Re: Highlight the current page menu item in WP-Theme

I think this is because the script hook does not reach into the WordPress structure. (Matt would have to confirm that)
But you should be able to add the functionality to WordPress via a plugin.
Or use a plugin that will allow you to add scripts.


Rod 
Just a user with way too much time on his hands.
www.rodbarbee.com
ttg-tips.com, Backlight 2/3 test site

Offline

#3 2019-11-29 09:19:20

Matthew
Administrator
From: San Francisco, CA
Registered: 2012-09-24
Posts: 5,795
Website

Re: Highlight the current page menu item in WP-Theme

The scripts hook is unavailable in Wordpress, due to how Wordpress handles the loading of Javascript. To use scripts in Wordpress, you need to enqueue them via a child theme. Here's how that works:
https://developer.wordpress.org/referen … ue_script/

Clear as mud? It's not me; blame WordPress.


Matt

The Turning Gate, http://theturninggate.net

Offline

#4 2019-11-30 00:16:46

volvoxturbo
Member
From: Barcelona - Frankfurt - Rome
Registered: 2012-11-12
Posts: 247
Website

Re: Highlight the current page menu item in WP-Theme

Rod & Matt,

thank you very much for your help.

I better not try to use scripts in wordpress :-|

Best regards,
Oliver

Offline

Board footer

Powered by FluxBB