Last active
November 23, 2019 20:53
-
-
Save nicdford/f3b70d756414d3f3731f to your computer and use it in GitHub Desktop.
A custom shortcode that makes a pods query and returns the value when the shortcode is called.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Display Wine Items | |
function cc_display_wine( $atts ) { | |
// Attributes | |
extract( shortcode_atts( | |
array( | |
'wine_id' => '1', | |
), $atts ) | |
); | |
$wine_id = $atts['wine_id']; | |
$wine = pods( 'wine', $wine_id ); | |
$wine_image = pods_image( $wine->field('product_image'), 'full' ); | |
$wc = '<div class="wine-feature-contain">'; | |
$wc .= $wine_image; | |
$wc .= '<div class="wine-feature-content hide">'; | |
$wc .= '<h4 class="sub-title">' . $wine->field( 'subtitle' ) . '</h4>'; | |
$wc .= '<h2 class="title">' . $wine->field( 'name' ) . '</h2>'; | |
$wc .= '<p>' . $wine->field( 'product_description' ) . '</p>'; | |
$wc .= '<a class="btn" href="' . $wine->field('op_url') . '" alt="' . $wine->field('name') . '" title="' . $wine->field('name') . '">Purchase</a>'; | |
$wc .= '</div>'; | |
$wc .= '</div>'; | |
return $wc; | |
} | |
add_shortcode( 'display_wine', 'cc_display_wine' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment