Skip to content

Instantly share code, notes, and snippets.

@stephandesouza
Last active December 22, 2015 06:18
Show Gist options
  • Select an option

  • Save stephandesouza/6429532 to your computer and use it in GitHub Desktop.

Select an option

Save stephandesouza/6429532 to your computer and use it in GitHub Desktop.
Exemplo de como chamar um formulário/include usando shortcode
[include_form template="contato" titulo="Formulário de Contato"]
// É feito o include do arquivo "forms/contato.php", com uma variável $titulo, com valor "Formulário de Contato"
add_shortcode('include_form', function($atts) {
$titulo = $atts['titulo'];
if (isset($atts['template'])) {
$layout = 'forms/' . $atts['template'] . '.php';
if (file_exists($layout)) {
include $layout;
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment