The Importance of Team Building
August 16, 2020Hacking Google Chrome’s Search Engine Settings for Efficiency
September 16, 2020Have you ever been working on a WordPress site and wanted to add something and could not find a widget that did what you needed? Maybe you found a plugin that does almost what you want (but not exactly). You may be tempted to change some of the code in the theme or plugin but this can lead to serious issues when you update versions. Here are two solutions to fixing the problem that will allow you to continue to update your theme and plugins.
1.) WP Coder
The first solution, when you want to make a quick change, is to use the WP Coder plugin that allows you to add your own custom HTML, CSS, and JS with ease. Once you download and activate the plugin you can navigate to the “WOW Plugins” tab and then click on the “WP Coder” link on the left side of the dashboard.
Navigate to the “Add new” tab, give it a name, and start coding. Once you finish coding you can copy the shortcode and place it on any page.
Because of the way WP Coder inserts your code you do not need to add link tags to your CSS or JS files, the plugin will automatically link them for you. Also, you can link external CSS or JS files under the “Includes file” tab. Here is an example of linking a JS file from a CDN. When linking to a CDN remember there can be caching issues. I recommend adding a version number (file.js?v=1) to your URL path. This way whenever you make changes to your linked file you can change the version in the URL to avoid any caching issues.
2.) Create your own plugin
The second solution is a good approach if you think you will use this functionality across multiple sites or if others using WordPress can benefit from it. It is possibly the best long-term option but also involves the most work. This will require at minimum a base knowledge of PHP (the core language of WordPress). The first thing you will need to do is to navigate to your plugins folder (located in the wp-content folder) and make a new folder for your plugin.
Then navigate into your plugin folder and create a .php file and some code.
<?php
/**
* Plugin Name: My Cool Plugin
* Plugin URI: http://www.mysite.com/my-cool-plugin
* Description: My First WordPress Plugin
* Version: 1.0
* Author: Your Name
* Author URI: http://www.mysite.com
*/
add_action( 'the_content', 'my_text' );
function my_text ( $content ) {
return $content .= '<p>Hello World!</p>';
}
?>
From here you can add the functionality. You can then go on to publish your plugin for others to use.
Conclusion
When you are working on a WordPress site and a new plugin or theme option cannot solve your problem try one of these approaches. If you would prefer someone else to take care of it for you, contact our dev team and get a quote. https://ckhconsulting.com/custom-software-development/