Add your selected dispensary location(s) to shortcode output

34 seconds

This is a code snippet that utilizes the Dispensary Locations add-on and displays the selected location(s) for each menu item through the included WP Dispensary action hook.

If you have multiple dispensaries or only deliver specific menu items to specific cities, you can utilize this code to display the location name that also links your website visitor to all menu items tagged with that location.

* Display your selected location(s) within the WP Dispensary shortcodes
* Requires the "Dispensary Locations" add-on from WP Dispensary
* @link
add_action( 'wpd_shortcode_inside_top', 'acme_mylocation' );
function acme_mylocation() {
global $post;
echo '<span class="mylocation">' . get_the_term_list( $post->ID, 'dispensary_locations', '', ', ' ) . '</span>';

You can add this quick CSS style to the mylocation class, positioning the name over top of your menu item’s featured image.

span.mylocation {
background: #FFF;
font-size: 13px;
padding: 10px;
position: absolute;
top: 5px;
right: 5px;

Required: Dispensary Locations add-on

Was this article helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *