• Resolved RayR75

    (@rayr75)


    Hi guys,

    On my local computer, Wordpess DOES give the “.current-menu-parent” & “.current-menu-ancestor” class to the navigation. However, theses classes do not appear on the live site. Meaning, the given styles do not work.

    Any ideas, solutions or work-around?

    Thank you & stay safe! ??

    (Ps. I do not work with a WP template)

Viewing 8 replies - 1 through 8 (of 8 total)
  • Moderator bcworkz

    (@bcworkz)

    The same theme in both cases? Same WP version? PHP version? Any difference could be the cause. Check the live site’s error log for further clues. Any warning or notice could potentially be the cause of the discrepancy.

    Thread Starter RayR75

    (@rayr75)

    Thanks! I have checked the WP version and PHP version. They are both identical.

    Then, I checked the local version for php errors, using the below code in the htaccess file, including the .txt file. Also no errors. But when pushing the 2 files to the live server, the website does not show up anymore. I had to take out those lines from htaccess file again. Not too familiar with backend stuff. So, I do not know if there are errors on the live site.

    php_flag log_errors on
    php_value error_reporting 32767
    php_value error_log "error_log.txt"
    Moderator bcworkz

    (@bcworkz)

    Live site error logs are normally accessed through the hosting account. Those classes are inserted by the default WP_Nav_Walker class. It’s possible for themes to override that with another walker class. You say you’re not working with a “template” which in WP is actually a single file within a theme, but I took your meaning to be the entire theme. But unless it’s a headless WP implementation, all WP sites use a theme of some sort, even if it’s the default theme.

    A difference in themes, or possibly even plugins, can cause the discrepancy. Besides the plugins you can see listed in the admin area, commercial hosts often add a hidden plugin in the /wp-content/mu-plugins/ folder. Such plugins wouldn’t typically alter nav walkers, but it would be possible.

    Thread Starter RayR75

    (@rayr75)

    Thank you again for spending your time on me. You brought me to the right path ?? To clarify, I am creating my own Theme/template. I was not explaining myself clearly enough, I think.

    So, I found an older error log(below). Apparently this also affects ‘WP_Nav_Walker’.

    I did some research and there is really not much info about this. There was only 1 website(https://php-download.com/package/johnpbloch/wordpress-core/file/wp-includes/functions.wp-scripts.php) that gave me the code that actually worked. But for this I had to replace the “functions.wp-scripts” file. Not something I am too happy about, to be honest.

    If you would know a different solution, I would love to hear it. For now, I will leave this code in there and search for some more answers.

    Thanks again and take care.

    PHP Fatal error:  Uncaught Error: Class 'WP_Scripts' not found in /wp-includes/functions.wp-scripts.php:23
    Stack trace:
    #0 /wp-includes/functions.wp-scripts.php(128): wp_scripts()
    #1 /wp-includes/widgets/class-wp-widget-text.php(58): wp_add_inline_script('text-widgets', 'wp.textWidgets....')
    #2 /wp-includes/class-wp-widget.php(252): WP_Widget_Text->_register_one(1)
    #3 /wp-includes/class-wp-widget-factory.php(102): WP_Widget->_register()
    #4 /wp-includes/class-wp-hook.php(287): WP_Widget_Factory->_register_widgets('')
    #5 /wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(NULL, Array)
    #6 /wp-includes/plugin.php(478): WP_ in /wp-includes/functions.wp-scripts.php on line 23
    • This reply was modified 4 years, 1 month ago by RayR75.
    • This reply was modified 4 years, 1 month ago by RayR75.
    Moderator bcworkz

    (@bcworkz)

    I recommend getting a fresh WP download, extracting the files, then doing a “manual update”, though if it’s the current version, you’re not really updating but freshening all the files.

    • This reply was modified 4 years, 1 month ago by bcworkz.
    Thread Starter RayR75

    (@rayr75)

    I got it!

    First, I updated WordPress on my staging site. This had no success. Then, I ended up re-uploading all my files again. No luck either. Then, I re-uploaded the database from the live site and stuck it in my staging site. That worked!?

    So, why still not on the live site?
    Well, it’s in the anchors!

    All my anchors are like this: https://www.website.com/#target. But on my clients domain I noticed that ‘www’ is missing in the URL. https://website.com/#target.

    The links will still work even though there is ‘www’ in the anchors. How ever, WordPress does not recognize this somehow and therefore will not give it the “current-menu-parent” and “current-menu-ancestor” class. It will only give these classes if the anchors are exactly the same as the url, so without ‘www’.

    Changing my menus anchors, fixed the problem.

    Amen! ??

    • This reply was modified 4 years, 1 month ago by RayR75.
    • This reply was modified 4 years, 1 month ago by RayR75.
    Moderator bcworkz

    (@bcworkz)

    Wow! That’s obscure. I glad you figured that one out, nice debugging work!

    Thread Starter RayR75

    (@rayr75)

    Well, it almost drove me insane but with your help, I got it now. So, thanks again! ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘.current-menu-parent class not given on live site.’ is closed to new replies.