I am creating a shortcode that will return an bunch of HTML elements. In the beginning it was fine to do it this way:
add_shortcode( 'about_us', 'shortcode_about' );
function shortcode_about() {
return "<div>Some content here.</div>";
}
But now I have to add a lot of content, which I think wouldn't look good as my functions.php
will be filled with a lot of this. I was wondering if I can just put it in an external file and include it.
I hoped something like this would work:
add_shortcode( 'about_us', 'shortcode_about' );
function shortcode_about() {
return include 'about-us.php';
}
But of course, it didn't. Any ideas on how to do this properly? Thanks
Use this
and in include.php
Try below code :
code in about-us.php