Sometimes when making a theme or plugin, you want to conditionally enqueue a script or style so that it does not load on pages where it is not used. This process is generally pretty straight forward, just add your enqueue functions inside of conditional statements like this: add_action(‘wp_enqueue_scripts’, ‘add_script_function’); function add_script_function() { if(condition one… Read more »
Posts Categorized:
How To:
How To: Change a Hex Color With PHP
I was recently working on developing a WordPress theme, which uses the customizer to change colors throughout the theme. Adjusting styles is pretty straight forward with Javascript or jQuery. You can add a script to overwrite the CSS style. Unfortunately in some cases, it is either not possible or practical to use JavaScript to change… Read more »
WordPress Image Orientation Detection
WordPress introduced responsive images in 4.4 which I find to work great in most cases. I have run across a few situations where I wanted more granular control over the image sizes and how they display based upon the images orientation. I decided the best way for me to implement something like this was using… Read more »
Customize WordPress Admin Login Logo
UPDATE If you are looking for a plugin that does this, take a look at Eazy Login Logo Adding a custom logo to the WordPress admin screen is a simple three step process that can give your website a personalized touch. The parts that display the login form information are the logo image, the link… Read more »
Add Template To Custom Post Type In A Plugin
This probably falls in the not the best idea for all applications category, depending on how you separate and manage functionality. The situation I used this in required that I create a plugin (you could also use your theme’s functions.php file) for a custom post type. I wanted the custom post type to have a… Read more »
Change Custom Post Type’s Default Visibility To Private
Look in the comments to Vikas’ solution… much cleaner solution! The number of functions built into WordPress is kind of incredible. Some of them get lost in the shuffle, one of those actions is post_submitbox_misc_actions. This action gives you the ability to add or adjust content or fields for a post or page when the… Read more »
Restrict Content Based On Username
On a recent project, I had to show specific posts & content for the correlated user. I used Advanced Custom Fields to set a client name field which I would manually enter to match to the login name for each user that I create. I am sure there are more efficient ways to accomplish this,… Read more »
Add Menu For Logged In Users
On a recent project I had to incorporate a different set of menus for users who were logged in. I used the function is_user_logged_in() to see if the user was logged in, with an if/else statement to change out the menu. function rjs_wp_nav_switch( $args = ” ) { if( is_user_logged_in() ) { $args[‘menu’] = ‘logged-in’;… Read more »
Add PNG Fallback Images For SVG
Scalable Vector Graphics or SVG have been around for quite a while, but they are having a sort of renaissance with responsive design, specifically for mobile devices. SVG has some major benifits over other file types. If you want to add SVGs to your website to replace PNGs or GIFs, there are some things you… Read more »
Optimize Specific Images For Mobile Devices With Responsive Design
Mobile devices have surpassed desktop usage. The approach developers take must adjust to these changes in usage behavior. I like to use responsive design principles to create solutions that adapt to a users device so that the site looks its best whether its viewed on a computer or a phone. One issue related to responsive… Read more »
Defer Parsing JavaScript For Slider Revolution
This is an old post and its information might be outdated. Please refer to Slider Revolution’s documentation for the most up to date information. I think Slider Revolution is OK. I use it because it has an easy to use admin UI and a lot of transitions. I can give a client access to it… Read more »
Secure Your Site: Vulnerabilities Found In WordPress All-In-One SEO
There are quite a few different WordPress plugins available that can add a variety of functionality to your WordPress website. Remember one of the plugins I developed, Eazy Twitter Cards? This is an example of how plugins can be one of the best parts of WordPress because it allows you to expand the capabilities of… Read more »