<?php
/**
* Callback functiom untuk shortcode [linkbox text="" url=""]
*
* @param Array $atts Array yang berisi atribut shortcode
* @return String $html String HTML yang dikembalikan ke display
*/
function linkbox_code( $attr=[] ) {
// Extract attribut dan masukkan ke variable
// dengan demikian dapat diakses via $param['text'] dan $param['url']
$param = shortcode_atts( array(
'text' => '',
'url' => ''
), $atts );
// Kembalikan HTML ke display, stylenya silahkan didefinisikan terpisaj
return '
<div class="linkbox">
<a href="'. $param['url'].'">'.$param['text'].'</a>
</div>
';
}
// Register [linkbox]
add_shortcode('linkbox', 'linkbox_code');
Created
April 24, 2018 09:56
-
-
Save tajidyakub/014e82f8c7da50fc646bea63ffe1ef83 to your computer and use it in GitHub Desktop.
Contoh callback function untuk shortcode di functions.php
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment