0

how can I create a shortcode (or something similar) to show the footer in somewhere on a page?

I tried with this but no results...

function show_footer() {
    return get_footer();
}
add_shortcode( 'show_f', 'show_footer' );

or this...

function show_footer() {
    get_footer();
}
add_shortcode( 'show_f', 'show_footer' );

any idea?

many thanks

6

get_footer() echos the contents of the footer.php file. add_shortcode() requires that the callback return the contents of the shortcode and not echo it. I suppose you could do something like this if you really want.

function show_footer() {
  ob_start();
  get_footer();
  return ob_get_clean();
}
add_shortcode( 'show_f', 'show_footer' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.