<?php
### the shortcode code add in theme’s functions.php file ###
// "do_shortcode" but without the wrapping <p> of Shortcodes
function do_shortcode_boc($content) {
$array = array (
'<p>[' => '[',
']</p>' => ']',
']<br />' => ']'
);
$content = strtr($content, $array);
$content = do_shortcode($content);
return $content;
}
function shortcode_shortcodename($atts, $content = null) {
$atts = shortcode_atts(
array(
'title' => '',
'image' => '',
), $atts);
$title = $atts['title'] ? $atts['title'] : '';
$image = $atts['image'] ? $atts['image'] : '';
$str = '<li>
<div class="icon_item">
<img src="'.$image.'">
<p>'.html_entity_decode($title).'</p>
<div class="icon_overlay">
<p>'.do_shortcode($content).'</p>
</div>
</div>
</li>';
return $str;
}
add_shortcode('shortcodename', 'shortcode_shortcodename');
?>
##### Using below code to display shortcode detail #####
[shortcodename title="my title" image="example.jpg"]
<div>
<p> Shortcode content </p>
</div>
[/shortcodename]
##### OR #####
<?php
echo do_shortcode('[shortcodename]');
?>
No comments:
Post a Comment