Insert HTML, JS, CSS, PHP Custom Code Anywhere in WordPress | Faster WordPress Development



Published
Insert Any Code Anywhere in WordPress. Done is better than perfect. Sometimes you just need things done quickly. Sometimes you just want to try some code without applying it to theme. There are many proper ways to add javascript, css, html or php in wordpress code but we are not talking about that. We just want to add code anywhere in wordpress quickly. I mean why do you have to install 10 plugins to add Google Analytics code, Facebook Pixel code, custom tracking code, Google Webmaster Code, Alexa Code, Bing Code, and all those verification codes?

We should have a theme independent centralized point to manage all these codes. So that when you change theme, you dont loose any code. Install a plugin called 'Head, Footer and Post Injections'.

Go to its settings. In first tab, you can add code in head section, add code right after body tag starts, or add code in footer section.

We can add code, text, image of anything for posts - before post or after post. Not just the before and after all posts, you can also insert content in middle of posts. You will have to create a marker for that. Marker is an html comment with specific text in it. Place marker anywhere in theme or in post or page, and replace it with code from this plugin.

Similarly you can insert content at start and end of pages in WordPress.

Then we have Generics. Here use another marker and use it in theme or post or page. I have placed it in single post content for the demo and replacing it from custom code inside plugin. In the 'advanced' tab you can control mobile agents and control head meta links. In notes, you can add 'notes' and 'code' that you can use later.

All in all this is a good plugin that allows you to inject CSS, JavaScript and PHP code throughout your site. It allows you to manually target specific areas of your site to show output from custom code. And you can also disable code injection for individual post or page by editing post or page. So this is how you can add custom code in your wordpress based site in areas that you want to - without adding more plugins. One use case is to keep all custom CSS and JavaScript code in one place until you move it to theme files.

I have similar solutions for more advanced use cases. Stay tuned for that.

This video has solutions for following:
- Add custom code (Javascript, CSS, HTML, PHP) anywhere in WordPress
- Add Google Analytics code, Facebook code, verification code in WordPress
- Add custom code to the head section only on the home page
- Add custom code to the head section and footer section of wordpress site
- Add custom scripts code on the footer
- Add PHP Code in WordPress
- Add custom code before and after each post content
- Add custom code before and after each page content
- How to add marker in Head, Footer and Post Injections plugin
- Add codes on top, bottom and in the middle of posts and pages
- Add code via shortcodes in WordPress
- Add code after the opening BODY tag or before closing BODY tag
- Add code anywhere on template using placeholders

If you are new to the channel, subscribe to learn more about web development, web application development, editing wordpress source code, how to create a website using wordpress, developing landing page in wordpress, working with child theme wordpress, custom wordpress theme development, wordpress plugin development, how to build a website with wordpress, create website with wordpress and related web development areas.

Thank You!
Category
Web design
Be the first to comment