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]
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.
$atts is required to create shortcode if you are passing $atts or not.