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

themes - How to find file that placed a line in my header

programmeradmin1浏览0评论

I am having a line of code in my header that I can't seem to find where it is coming from, checked both files and database, am sure am missing something, are you guys aware of any methods to find for pieces of code where they are called from ?

Kind regards, Cristian

I am having a line of code in my header that I can't seem to find where it is coming from, checked both files and database, am sure am missing something, are you guys aware of any methods to find for pieces of code where they are called from ?

Kind regards, Cristian

Share Improve this question edited Apr 2, 2019 at 11:12 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Apr 1, 2019 at 12:13 Cristian TrandafirCristian Trandafir 11 bronze badge 6
  • give us a little more details on what the line is please. – mrben522 Commented Apr 1, 2019 at 12:32
  • Search your entire installation for 'send_header'. You can also try changing theme and turning plugins on and off to see if / when it goes away. Is it one that WordPress generates by default, e.g. canonical page links and links to the REST API, or something a plugin might generate e.g. Strict-Transport-Security, or something else altogether? – Rup Commented Apr 1, 2019 at 12:34
  • @mrben522 sadaghian line in header: <script async="" src="//www.google-analytics/analytics.js"></script> The website was created maybe 3-4 years ago, GA was put on it, but I guess the plugin has been removed and somehow this is still called, I need to remove it in order to start with Google Tag Manager. I've checked the entire website and in Database, what I found I deleted, yet it still appears in my header. – Cristian Trandafir Commented Apr 1, 2019 at 13:06
  • Oh you meant the HTML <head> - I thought you meant HTTP headers. But the advice about changing theme and plugins stands. If this script tag isn't in your theme then it'll be a plugin hooking wp_head and writing it; you could try removing the wp_head() call from your theme to see if that removes the script tag, else you'll have to search through everything that hooks wp_head to see which one is doing it. – Rup Commented Apr 1, 2019 at 16:36
  • If you are familiar with using the command line, you can try finding the file using grep: grep -rn 'www.google-analytics' will return the files and lines containing the string "www.google-analytics" – phatskat Commented Apr 1, 2019 at 18:02
 |  Show 1 more comment

1 Answer 1

Reset to default 0

Install the String Locator WordPress plugin (free): https://wordpress/plugins/string-locator/

You can then search through all the files on your server, looking for google-analytics and do some inspection on the files found to see if any of those are the culprit. Chances are it's hard coded in your theme header files, or there's a plugin that's enqueuing the script.

You can also use a DB search and replace plugin, just set config to do a "dry run" to search for google-analytics to see if it's saved in the db anywhere: https://wordpress/plugins/search-and-replace/

I would also recommend that you try using a different browser as well to check this, to make sure some Chrome (or whatever browser you're using), that an extension is not injecting that on the page.

发布评论

评论列表(0)

  1. 暂无评论