Create a Custom Shortcode in Essential Grid

Create a shortcode using PHP and a PHP function that can read the Post ID and returns anything into the grid item.

The example below will show you how to create a shortcode that displays a date on the grid items with different date format.

1. Add the following code to your theme’s “functions.php” file.

function tp_custom_shortcode( $atts ) {
    $p = shortcode_atts( array(
        'id' => 0
    ), $atts );
 
//set your preferred time format https://codex.wordpress.org/Formatting_Date_and_Time
$h_time = get_post_time( 'l, F j, Y', false, $p['id'] );
 
return $h_time;
 
}
add_shortcode( 'custom_time_format', 'tp_custom_shortcode' );

2. Edit the grid skin and insert the shortcode into a Text/HTML layer.

[custom_time_format id=%post_id%]
Create a Custom Shortcode in Essential Grid

Further Resources for Web Design and Development Enthusiasts

Alright! We've embarked on quite an adventure exploring the realms of this topic. But why stop there? The world of web design and development is vast, and there's always more to learn and discover. Let's dive into some resources that'll keep your knowledge fresh, your skills sharp, and your passion ignited:

The Author

KC

Strength does not come from winning. Your struggles develop your strengths. When you go through hardships and decide not to surrender, that is strength.

Liked this Post?
Please Share it!