Skip to main content

Hidden Gems in WordPress

By February 20, 2016Blog, Snippets, Wordpress
WordPress Tutorials by Allure Web Solutions

Detect Mobile Devices Using wp_is_mobile()

This aptly named function detects when a user is on a mobile device and allows you to display content accordingly. Since this is a conditional tag it returns true or false depending on the scenario.

<?php if( wp_is_mobile() ) : ?>
    // what do to on mobile
<?php endif ?>

Cloaking Email Addresses in Your Content Using antispambot()

In my post about must-have WordPress functions for every custom theme project, I described a method on how to have every single email address automatically converted by antispambot(). So, below I’ll show a method of how to do it manually for each email address using a shortcode. Just add the following code to your theme’s functions.php file:

    function antispambot_sc( $atts ) {
        extract( shortcode_atts( array(
            'email' => ''
        ), $atts ) );
        return antispambot( $email );
    add_shortcode( 'antispambot', 'antispambot_sc' );
    // Usage: [antispambot email=""]

Automatically Make URLs Into Links

If you don’t want to manually create a link every time you write a URL, you can use this simple little function to create a link automatically.

add_filter( 'the_content', 'make_clickable', 12 );

Use Masonry Layout For Your Posts

WordPress care functions have a built in Masonry script that you can activate with the following code:

// Pull Masonry from the core of WordPress
wp_enqueue_script( 'masonry' );

There is some further setup needed to get it working though. You will have to make some changes to your template file, add some javascript, and minor CSS edits. I won’t go into the details here, but you can check out my full tutorial on how to add masonry with infinite scroll to WordPress.


Author allure

More posts by allure

Leave a Reply

Designed by

best down free | web phu nu so | toc dep 2017