Ecommerce Shopify WordPress Discussion

Issue with JavaScript in WordPress When Logging In

I have this JS code for a YouTube video views counter, hosted at the root of my WordPress site: <script src="/wp-admin/js/01_YTapi.js"></script> This script is called in posts through the following div: <div class="ViewCountContainer" style="margin-bottom: 20px; text-align: center;" data-video-id="XqZsoesa55w" > Loading... </div> The code works correctly, displaying the views counter. However, when I log in to WordPress, the script stops working, and the message "Loading..." remains, without displaying the actual views. In the Chrome console, I see this error message: Request URL: https//PageAddress.com/PostName/wp-admin/js/01_YTapi.js Status Code: 404 Not Found Instead of executing the JS, its address is added to the end of the post address, resulting in a page not found (404). I need help understanding why the script stops working after logging in to WordPress and how I can fix this issue. I appreciate any guidance or suggestions to resolve this problem. Thank you!
@Cabrerahector, Thank you for the observation. I didn't know that custom scripts shouldn't be put in these places. I'll fix that as soon as possible. @Ceejayoz, ChatGPT generated the code with the slash (src="/wp-admin/js/01_YTapi.js), but when checking on the site, I noticed it was without the slash (src="wp-admin/js/01_YTapi.js). After seeing your comment, I decided to add the slash just to see what would happen, and, by sheer luck, it resolved the issue. Thanks to both for the tips and for helping me solve my problem!

January 23, 2024

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.