Reputation: 10198
In my theme function.php i am trying to add shortcodes for myHeader, myFooter etc .
Inside myHeader(), myFooter() function i added another function like fn_1(), fn_2(), fn3_() etc these function would be change weekly or monthly basis.
Is it possible to call a shortcode as written below
function myHeader(){
fn_1();
//fn_2();
}
function myFooter(){
fn_2();
// fn_3();
}
add_shortcode('myFooter', 'myHeader');
add_shortcode('myFooter', 'myFooter');
function fn_1(){
return 'something for 1';
}
function fn_2(){
return 'something for 2';
}
function fn_3(){
return 'something for 3';
}
In my post i call my shortcode as [myHeader] and [myFooter]
Upvotes: 1
Views: 1080
Reputation: 193
$atts is required to create shortcode if you are passing $atts or not.
Upvotes: 0
Reputation: 424
It is possible, you just need to return something inside your shortcode methods. Shortcode functions also require some variables, though they don't actually have to be used.
eg.
function myHeader($atts, $content = null){
$temp = fn_1();
return $temp;
}
Upvotes: 3