Blog Archives

Display First Few Characters Of A WordPress Post Outside The Loop

<?php echo apply_filters( ‘the_content’, wp_trim_words( strip_tags( get_post_field(‘post_content’, $recent[“ID”]) ), 55 ) ); ?> where $recent[“ID”] is of the ID of the post. If you are already querying the post and already have a WP_Post object, you can simply use this:

Posted in WordPress Tagged with:

Query Anything On WordPress Anywhere

<?php $args = array(       ‘numberposts’   => ‘3’,       ‘post_status’   => ‘publish’,     ); $recent_posts = wp_get_recent_posts( $args ); // Loop each post foreach( $recent_posts as $recent ) {   echo get_the_title($recent[“ID”]);   echo $recent[“post_content”]; } wp_reset_query(); ?> Refer the WP_Query class reference for a

Posted in WordPress Tagged with:

Conditionally Display Fields In Contact Form 7 With Simple JavaScript

In this tutorial, learn how to conditionally display form fields using simple inline JavaScript. Add-on plugins are an overkill for most simple use cases.

Posted in Tutorials, WordPress Tagged with: , , ,

Easily Detect Mobile Device vs Desktop – A Developers Story

A simple way to detect if the user is browsing a website on a mobile device or a desktop. Also includes code bits for mobile browser detection using user agent in PHP and links to resources for other languages.

Posted in Mobile, Tutorials Tagged with: , , ,

Automatically Add Image Caption, Description And Alt Text From Image Title

Here is a handy code snippet that once added to your functions.php will automatically set the Image Title, Image Caption, Image Alt Text and Description the next time you upload an image into WordPress.

Posted in WordPress Tagged with: , , ,
Email Stamp

Free Newsletter

Get my newest blog posts and insider tips. No more than a few emails a year.

Just enter your email address below and click Sign Up Now

Please enter all required fields
Correct invalid entries

You have Successfully Subscribed!