The problem seems to be with the custom single store template I created. I’m using a child theme of Twenty Sixteen. I figure that I’m making an error. If you’re able to take a look and let me know, that would be really appreciated and also helpful for other people working with Twenty Sixteen.
I can get the example working for a child theme of Twenty Fifteen, however I’m having trouble, see code below, making the appropriate changes to the HTML structure of single.php for Twenty Sixteen.
When editing a store, using a basic img tag works correctly. However when I click the button to ‘Add Media’ then there is a problem. The img tag includes a class with alignment. If I remove the class, then the map displays. But if the class remains class="aligncenter size-full wp-image-156"
, then the map will disappear.
<?php
/**
* Single WPSL store template for the Twenty Sixteen theme.
*
* @package WordPress
* @subpackage Twenty_Seventeen
*/
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<h1 class="entry-title"><?php single_post_title(); ?></h1>
</header>
<div class="entry-content">
<?php
global $post;
$queried_object = get_queried_object();
// Add the map shortcode
echo do_shortcode( '[wpsl_map zoom="16"]' );
// Add the address shortcode
echo do_shortcode( '[wpsl_address]' );
// Add link to directions
$address = get_post_meta( $queried_object->ID, 'wpsl_address', true );
$city = get_post_meta( $queried_object->ID, 'wpsl_city', true );
$country = get_post_meta( $queried_object->ID, 'wpsl_country', true );
$destination = $address . ',' . $city . ',' . $country;
$direction_url = "https://maps.google.com/maps?saddr=&daddr=" . urlencode( $destination ) . "";
echo '<p><a target="_blank" href="' . esc_url( $direction_url ) . '">' . __( 'Directions', 'wpsl' ) . '</a></p>';
// Add the hours shortcode
echo do_shortcode( '[wpsl_hours]' );
// Add featured image
echo get_the_post_thumbnail( $queried_object->ID, 'large' );
// Add the content
$post = get_post( $queried_object->ID );
setup_postdata( $post );
the_content();
wp_reset_postdata( $post );
?>
</div>
</article>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>