php - Wordpress shortcode with separate template/file? -
php - Wordpress shortcode with separate template/file? -
i'm @ stage of learning wordpress (and shortcode), bear me:
to me, shortcodes seem swiss regular army knife of not having utilize page-specific templates everything. build many pages in wysiwyg possible, need (reusable) php stuff displaying stuff in way.
having googled lot, seems me way shortcodes like:
class="lang-php prettyprint-override">function caption_shortcode( $atts, $content = null ) { homecoming '<span class="caption">' . $content . '</span>'; } my question is, possible set html in separate template-ish file? seems wrong , verbose set markup here, escape quotes, et.c. template-file shortcode, shortcode can pass info transfer object (or scoped variables). so: display in template-file, logic finding info (to pass said template-file) in shortcode-function (wherever may defined, functions.php, separate plugin, or something).
you can set-up views(php files) , include partial views ones. wordpress allows templates includes within other templates ensure code reuse , modifiable kid themes. can utilize function include those
get_template_part( $slug ); however, in case, short code function needs homecoming value caller function. so, setup not work.
php wordpress
Comments
Post a Comment