4 Wordpress shortcodes to change your life as a developer

Gutenberg WordPress helper shortcode

Ramesh Dura
1 min readJun 22, 2019

Paste the following codes in your functions.php

// Comment shortcode use like [commentor comment=””]
function commentor_shortcode( $atts ) {
extract( shortcode_atts(
array(
‘comment’ => ‘’,
), $atts )
);

if(!empty($comment)){$html = ‘<! — ‘.$comment.’ →’; return $html;}
$html = ‘<div>’;
return $html;
}
add_shortcode( ‘commentor’, ‘commentor_shortcode’ );

// Clear shortcode use like [clear]
function clearfix_shortcode( $atts ) {
$html = ‘<div class=”clear”></div>’;
return $html;
}
add_shortcode( ‘clear’, ‘clearfix_shortcode’ );

// Div shortcode use like [divopen class=”classA classB”]
function divopen_shortcode( $atts ) {
extract( shortcode_atts(
array(
‘class’ => ‘’
), $atts )
);

if(!empty($class)){$html = ‘<div class=”’.$class.’”>’; return $html;}
$html = ‘<div>’;
return $html;
}
add_shortcode( ‘divopen’, ‘divopen_shortcode’ );

// Div close shortcode use like [divclose]
function divclose_shortcode( ) {
$html = ‘</div>’;
return $html;
}
add_shortcode( ‘divclose’, ‘divclose_shortcode’ );

--

--

Ramesh Dura
Ramesh Dura

Written by Ramesh Dura

Student of Literature & Web Developer

No responses yet