Grid WUD short code in PHP pages

How to insert a Grid WUD or other short code into a PHP page.

Do you want more info about placing a short code in PHP?
Use the contact page or go to our support forum!

The PHP Code explained:
if (function_exists(‘grid_wud_funcs’)){ … }
This will search or a specific plugin function exists.
In this sample we have used our own function: grid_wud_funcs, but this can be any kind of function from any plugin.

do_shortcode(‘[gridwud slug="type-here-your-slug"]‘);
do_shortcode is a WordPress function, which calls the short code mentioned between the [ … ].
In this sample we have used our own short code: ‘gridwud slug=”type-here-your-slug”, but this can be any kind of short code from any plugin.

To add a Grid WUD short code directly into your PHP page(s) you can use following code between the <?php and ?> tag.

<?php
if (function_exists('grid_wud_funcs'))
{
echo '<div style="type-here-css-values">';
echo do_shortcode('[gridwud slug="type-here-your-slug"]');
echo '</div>';
}
?>

Replace: “type-here-css-values” with CSS values (width:xx; height:xx; … …)
Replace: “type-here-your-slug” with your WordPress slug.

Sample PHP code

<?php
if (function_exists('grid_wud_funcs'))
{
echo '<div style="max-width:80%">';
echo do_shortcode('[gridwud slug="my-home"]');
echo '</div>';
}
?>

Or in one line …
See extra backslash \"  because " is already used before.

<?php
if (function_exists('grid_wud_funcs'))
{
echo '<div style="max-width:80%">'.do_shortcode("[gridwud slug=\"my-home\"]").'</div>';
}
?>

You do not have to include the div tag, if your grids/tiles are displaying well without the div tag.

<?php
if (function_exists('grid_wud_funcs'))
{
echo do_shortcode('[gridwud slug="my-home"]');
}
?>

And if you want it to be displayed on the front-page only

<?php
if (function_exists('grid_wud_funcs') && ( is_front_page() || is_home()) )
{
echo do_shortcode('[gridwud slug="my-home"]');
}
?>

Sample (in footer.php)
_TEMPO