Hi Guys.. I wanted to do the same thing.. so i hacked the code a little by using a div…
Here is the code as it exists:
// process a shortcode for a voucher
function voucher_do_voucher_shortcode( $atts ) {
extract( shortcode_atts( array(
'id' => '',
'preview' => ''
), $atts ) );
if ( $id != "" ) {
$voucher = voucherpress_get_voucher( $id );
if ( $voucher && ( $voucher->expiry == "" || (int)$voucher->expiry == 0 || (int)$voucher->expiry > time() ) ) {
if ( $preview == 'true' ) {
return '<a href="' . voucherpress_link( $voucher->guid ) . '"><code></code><img src="' . get_option( "siteurl" ) . '/wp-content/plugins/voucherpress/templates/' . $voucher->template . '_thumb.jpg" alt="' . htmlspecialchars( $voucher->name ) . '" /></a>';
} else {
return '<a href="' . voucherpress_link( $voucher->guid ) . '">' . htmlspecialchars( $voucher->name ) . '</a>';
}
} else {
$r = "<!-- The shortcode for voucher " . $id . " is displaying nothing because the voucher was not found, or the expiry date has passed";
if ( $voucher ) {
$r .= ". Voucher found, expiry: '" . $voucher->expiry . "'";
}
$r .= " -->";
return $r;
}
}
}
Here is the modified code:
// process a shortcode for a voucher
function voucher_do_voucher_shortcode( $atts ) {
extract( shortcode_atts( array(
'id' => '',
'preview' => ''
), $atts ) );
if ( $id != "" ) {
$voucher = voucherpress_get_voucher( $id );
if ( $voucher && ( $voucher->expiry == "" || (int)$voucher->expiry == 0 || (int)$voucher->expiry > time() ) ) {
if ( $preview == 'true' ) {
return '<a href="' . voucherpress_link( $voucher->guid ) . '"><div style="position: absolute; width:400; height:0;">' . htmlspecialchars( $voucher->name ) . '</div><img src="' . get_option( "siteurl" ) . '/wp-content/plugins/voucherpress/templates/' . $voucher->template . '_thumb.jpg" alt="' . htmlspecialchars( $voucher->name ) . '" /></a>';
} else {
return '<a href="' . voucherpress_link( $voucher->guid ) . '">' . htmlspecialchars( $voucher->name ) . '</a>';
}
} else {
$r = "<!-- The shortcode for voucher " . $id . " is displaying nothing because the voucher was not found, or the expiry date has passed";
if ( $voucher ) {
$r .= ". Voucher found, expiry: '" . $voucher->expiry . "'";
}
$r .= " -->";
return $r;
}
}
}
The above worked for me… you can see an example at https://www.korma-sutra.com on the sidebar under section called vouchers…
With a little more styling one can make it look better… I just did a quick and dirty.. but it works.. It uses the voucher title as the text to display ontop of the image of the voucher… essentially creating the appearance of a preprinted voucher…