How to create conditional “IF” statements for WordPress custom meta fields

Sometimes you would want to output content based on WordPress meta fields – and use conditions (statements) based on wether or not the meta fields has data etc. In this example we are using a meta field with the name: “youtube-video-id” and value: “abcd1234”. Instructions Add this code to your single.php file (or similar). <?php […]

How to display content for mobile- or desktop only using WordPress “wp_is_mobile”.

Did you know that you can use WordPress built-in “mobile detect” function wp_is_mobile to create a simple shortcode that can hide certain parts of your content from mobile visitors and-/or desktop visitors. The wp_is_mobile function returns true when your site is viewed from a mobile browser. Using this function you can create adaptive-/responsive wordpress themes […]


For modern browsers, and IE9+, you can listen for the DOMContentLoaded event: document.addEventListener(“DOMContentLoaded”, function(){ // Handler when the DOM is fully loaded }); But, note that the callback will not be executed if the event has already fired. To make sure the callback is always run, jQuery checks the readyState of a document (reference) and, if it’s already complete, executes […]