最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - Changing the pointing of assets from old server to new server

programmeradmin5浏览0评论

The assets [javascripts,css and other files] are loading from the old server. I need to point them all to the new server url.How to do it?

They have to be replaced with the new domain url.

The assets [javascripts,css and other files] are loading from the old server. I need to point them all to the new server url.How to do it?

They have to be replaced with the new domain url.

Share Improve this question asked Oct 1, 2020 at 6:55 Presales EverteamPresales Everteam 1
Add a comment  | 

1 Answer 1

Reset to default 0

Usually scripts and styles are loaded with wp_enqueue_script or wp_enqueue_style in the theme's functions.php. That's the most common scenario.

This function takes an $src parameter which is the absolute URL to the resource, and the best practice is to use get_stylesheet_directory_uri to retrieve the URL to the folder containing the script. This way, if the site is moved, the URL will change with it.

It might be that those were hardcoded strings. That's why they're still the old ones.

See examples below https://developer.wordpress/reference/functions/wp_enqueue_script/#user-contributed-notes

Scripts and styles loaded from a plugin should use plugins_url in the $src parameter. wp_enqueue_style( 'prm_style', plugins_url('/assets/style.css', __FILE__ ) );

发布评论

评论列表(0)

  1. 暂无评论