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

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!