Code your own Template

Advanced users can make use of our plugin hooks to output their own HTML instead of using our Template Editor. This can be done by adding the following code to your (child) theme’s functions.php file:

function wpupg_custom_template( $output, $template, $post, $classes ) {
    ob_start();
    ?>

<div id="wpupg-container-post-<?php echo $post->ID; ?>" data-id="<?php echo $post->ID; ?>" data-permalink="<?php echo get_post_permalink( $post->ID ); ?>" class="<?php echo implode( ' ', $classes ); ?>">
        This is the post item.
    </div>

    <?php
    $output = ob_get_contents();
    ob_end_clean();

    return $output;
}
add_filter( 'wpupg_output_grid_html', 'wpupg_custom_template', 10, 4 );

The following variables are available to you:

  • $output – Output generated by the Template Editor
  • $template – Template that was used to generate the output
  • $post – WP Post object for the current post item
  • $classes – Classes required for the filtering to work