How does WordPress add head code to articles? WP plugin optimizes head code

The Header Footer Code Manager plugin , which was introduced in the article " How to Customize a WordPress Header? Installing a WordPress Footer and Header Plugin , " currently cannot add PHP code...

Therefore, a search on the WordPress plugin website revealed a WordPress plugin that allows adding PHP code to headers and footers—the Head, Footer and Post Injections plugin.

What is the Head, Footer and Post Injections plugin?

Add PHP/JavaScript/CSS code to the header and footer of a specified article in WordPress

The Head, Footer and Post Injections plugin allows your WordPress site to add the following common codes to the Header without installing more than 10 plugins:

  • Google Analytics
  • Facebook pixel
  • customizetracking code
  • Google DFP tags
  • Google Webmaster/Alexa/Bing/Trade doubler Verification code

You can centrally manage your code by simply enabling the Head, Footer, and Post Injections plugin, and you'll never have to worry about losing the code you added when changing your WordPress theme again.

Why install the Head, Footer and Post Injections plugin?

Do you need to insert ad banners above or after your post content?

Yes, using the Head, Footer, and Post Injections plugin , you can add code to the top and bottom of an article post or page:

  • in articles and pagestop, bottom and middleadd code;
  • Differentiate between mobile and desktop(You wouldn't show the same ad format on both, would you?);
  • separate post and page configurations;
  • PHP code can be added;
  • Enable shortcodes.
  • just after the open BODY tab
  • in the middle of the post content (using configurable rules)
  • anywhere on the template (with placeholders)

WordPress article optimization head code

Under the "Advanced Features" tab of the Head, Footer and Post Injections plugin , you can optimize the head code of WordPress posts:

  1. CSS merged style id removed
  2. CSS merged media removal

WordPress article optimization head code

The following is an article from the developers of the Head, Footer, and Post Injections plugin :

CSS merged style id removed

  • WordPress has a great feature that we can name "Style Queue".Every plugin that needs to add its style to a page can ask WordPress to "queue" it, and WordPress will add it correctly.
  • But WordPress even adds a unique ID to this CSS, so every module or plugin that tries to merge CSS is usually blocked.Giving a style resource a unique id means someone can reference it, and merging breaks that uniqueness.
  • Usually the id is not used at all, and if removed, CSS merging can happen.For example mod_pagespeed requires the id to be removed otherwise it won't merge the styles.
  • (It also needs to remove compression, so if you use a caching plugin, disable compression when using mod_pagespeed).

CSS merged media removal

  • If you've read the paragraph above, you should know that another CSS link property affects merging, and it's the "media" property. The media attribute is primarily used to add a set of styles to change the appearance of the page when printed, even though there are more options and uses available.
  • Usually all plugins add CSS with the "media" property set to "all", and all of these can be combined.But there are plugins that add CSS to "screen" with media set to "screen", which may or may not be important in your blog (read more about media types here).
  • If it's okay to remove media attributes in your blog, you should benefit from broader style merging.The "print" media type is reserved anyway.

Head, Footer and Post Injections plugin download

Comment

Your email address will not be published. Required fields are marked with * .

Scroll to Top