How to change a WordPress plugin function using action hooks

This is just one of the many possible scenarios on how to change a function in a WordPress plugin, but let me show you a real world example from Easy Property Listings, a really great and customizable real estate plugin. My client wanted to remove the <a> element from featured image on single property listing page. The thing was that if you click on that image, it would take you to that same post anyway, so having a link there was a redundant thing to have.

(more…)

Read More

How to copy text from website to clipboard

So this is the scenario - you have this text on your website and would like to have a button that would allow the visitor to copy the text into clipboard using one click, without requiring them to select the text manually. Thankfully, there is a clipboard.js library, allowing us to perform different kinds of scenarios easily. Let me show you one of the examples, implemented into WordPress.

(more…)

Read More

Creating responsive charts with JavaScript

Back in the day when web developers didn't have to care about responsive layouts, life was easier in some cases. For example - charts. There are quite a lot of types of charts and in the beginnings of responsive web, creating responsive charts surely wasn't a trivial task. But nowadays, given that there are thousands of different JavaScript libraries, it is no surprise that there are excellent libraries for charts. One of my favorite is Chart.js. In case you want to use it on WordPress, you can code it manually or use a WordPress Charts plugin. (more…)

Read More

Creating media queries using Modernizr and jQuery

Modernizr can do lots of things - one of them is the ability to mix media query function with jQuery functions. Although there are other ways to achieve this, even (or especially) within jQuery itself, if using Modernizr for some other things on your website, you can try something like the following:

and finally some HTML:

If this piece of HTML is loaded on resolution below 480px, .myClass will be added.

Read More

How to add custom CSS class depending on the template

I know that you can achieve the same by using global variables, but this is also one of the ways to add custom class depending on which page template has been loaded (you would add this into functions.php):

(more…)

Read More

How to enable shortcodes in text widgets

This could be one of the shortest tutorials ever, but still, some may find it useful - in order to activate the ability of regular text widgets to render shortcodes, all that needs to be done is the following:

You would put this into functions.php or in custom functions plugin. And that's all. No need for custom plugins that offer custom shortcode widgets, PHP widgets with do_shortcode(), etc.

 

Read More