Skip to content

Instantly share code, notes, and snippets.

@bhubbard
Last active August 31, 2021 13:41
Show Gist options
  • Save bhubbard/f54b531f87690b857c35 to your computer and use it in GitHub Desktop.
Save bhubbard/f54b531f87690b857c35 to your computer and use it in GitHub Desktop.
WordPress Templates for Local SEO by Yoast Multiple Locations CPT
<?php
/*
Our Template Page for Single Locations created with Local SEO by Yoast
Local SEO is good at at formatting this data use the schema format, please make sure you continue to support it.
*/
get_header(); ?>
<h1>Locations</h1>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php echo antispambot(get_post_meta( get_the_ID() , '_wpseo_business_email', true )); // Email ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_url', true ); // Buisness URL ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_coordinates_lat', true ); // Latitude ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_coordinates_long', true ); // Longitude ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_address', true ); // ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_city', true ); // ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_state', true ); // ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_zipcode', true ); // ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_country', true ); // ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_phone', true ); // ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_phone_2nd', true ); // ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_fax', true ); // ?>
<ul>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_monday_from', true ); // Monday From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_monday_to', true ); // Monday To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_monday_second_from', true ); // Monday Second From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_monday_second_to', true ); // Monday Second To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_tuesday_from', true ); // Tuesday From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_tuesday_to', true ); // Tuesday To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_tuesday_second_from', true ); // Tuesday Second From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_tuesday_second_to', true ); // Tuesday Second To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_wednesday_from', true ); // Wednesday From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_wednesday_to', true ); // Wednesday To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_wednesday_second_from', true ); // Wednesday Second From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_wednesday_second_to', true ); // Wednesday Second To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_thursday_from', true ); // Thursday From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_thursday_to', true ); // Thursday To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_thursday_second_from', true ); // Thursday Second From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_thursday_second_to', true ); // Thursday Second To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_friday_from', true ); // Friday From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_friday_to', true ); // Friday To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_friday_second_from', true ); // Friday Second From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_friday_second_to', true ); // Friday Second To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_saturday_from', true ); // Saturday From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_saturday_to', true ); // Saturday To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_saturday_second_from', true ); // Saturday Second From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_saturday_second_to', true ); // Saturday Second To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_sunday_from', true ); // Sunday From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_sunday_to', true ); // Sunday To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_sunday_second_from', true ); // Sunday Second From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_sunday_second_to', true ); // Sunday Second To ?></li>
</ul>
<?php
$args = array(
'id' => 'all',
'width' => 300,
'height' => 300
);
echo wpseo_local_show_map( $args );
?>
<?php echo get_the_term_list( get_the_ID() , 'wpseo_locations_category', '<p>', ', ', '</p>' ); ?>
<?php endwhile; else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
<?php get_footer(); ?>
<?php
/*
Our Template Page for Single Locations created with Local SEO by Yoast
Local SEO is good at at formatting this data use the schema format, please make sure you continue to support it.
*/
get_header(); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h1><?php the_title(); ?></h1>
<?php the_content(); ?>
<?php echo antispambot(get_post_meta( get_the_ID() , '_wpseo_business_email', true )); // Email ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_url', true ); // Buisness URL ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_coordinates_lat', true ); // Latitude ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_coordinates_long', true ); // Longitude ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_address', true ); // ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_city', true ); // ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_state', true ); // ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_zipcode', true ); // ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_country', true ); // ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_phone', true ); // ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_phone_2nd', true ); // ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_fax', true ); // ?>
<ul>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_monday_from', true ); // Monday From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_monday_to', true ); // Monday To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_monday_second_from', true ); // Monday Second From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_monday_second_to', true ); // Monday Second To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_tuesday_from', true ); // Tuesday From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_tuesday_to', true ); // Tuesday To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_tuesday_second_from', true ); // Tuesday Second From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_tuesday_second_to', true ); // Tuesday Second To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_wednesday_from', true ); // Wednesday From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_wednesday_to', true ); // Wednesday To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_wednesday_second_from', true ); // Wednesday Second From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_wednesday_second_to', true ); // Wednesday Second To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_thursday_from', true ); // Thursday From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_thursday_to', true ); // Thursday To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_thursday_second_from', true ); // Thursday Second From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_thursday_second_to', true ); // Thursday Second To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_friday_from', true ); // Friday From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_friday_to', true ); // Friday To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_friday_second_from', true ); // Friday Second From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_friday_second_to', true ); // Friday Second To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_saturday_from', true ); // Saturday From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_saturday_to', true ); // Saturday To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_saturday_second_from', true ); // Saturday Second From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_saturday_second_to', true ); // Saturday Second To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_sunday_from', true ); // Sunday From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_sunday_to', true ); // Sunday To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_sunday_second_from', true ); // Sunday Second From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_sunday_second_to', true ); // Sunday Second To ?></li>
</ul>
<?php
$args = array(
'id' => 'all',
'width' => 300,
'height' => 300
);
echo wpseo_local_show_map( $args );
?>
<?php echo get_the_term_list( get_the_ID() , 'wpseo_locations_category', '<p>', ', ', '</p>' ); ?>
<?php endwhile; else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
<?php get_footer(); ?>
<?php
/*
Our Template Page for Single Locations created with Local SEO by Yoast
Local SEO is good at at formatting this data use the schema format, please make sure you continue to support it.
*/
get_header(); ?>
<h1 class="entry-title headline">Locations for <?php $term = $wp_query->queried_object; echo $term->name; ?> </h1>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<?php echo antispambot(get_post_meta( get_the_ID() , '_wpseo_business_email', true )); // Email ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_url', true ); // Buisness URL ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_coordinates_lat', true ); // Latitude ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_coordinates_long', true ); // Longitude ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_address', true ); // ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_city', true ); // ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_state', true ); // ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_zipcode', true ); // ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_country', true ); // ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_phone', true ); // ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_phone_2nd', true ); // ?>
<?php echo get_post_meta( get_the_ID() , '_wpseo_business_fax', true ); // ?>
<ul>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_monday_from', true ); // Monday From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_monday_to', true ); // Monday To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_monday_second_from', true ); // Monday Second From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_monday_second_to', true ); // Monday Second To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_tuesday_from', true ); // Tuesday From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_tuesday_to', true ); // Tuesday To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_tuesday_second_from', true ); // Tuesday Second From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_tuesday_second_to', true ); // Tuesday Second To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_wednesday_from', true ); // Wednesday From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_wednesday_to', true ); // Wednesday To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_wednesday_second_from', true ); // Wednesday Second From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_wednesday_second_to', true ); // Wednesday Second To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_thursday_from', true ); // Thursday From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_thursday_to', true ); // Thursday To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_thursday_second_from', true ); // Thursday Second From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_thursday_second_to', true ); // Thursday Second To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_friday_from', true ); // Friday From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_friday_to', true ); // Friday To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_friday_second_from', true ); // Friday Second From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_friday_second_to', true ); // Friday Second To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_saturday_from', true ); // Saturday From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_saturday_to', true ); // Saturday To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_saturday_second_from', true ); // Saturday Second From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_saturday_second_to', true ); // Saturday Second To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_sunday_from', true ); // Sunday From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_sunday_to', true ); // Sunday To ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_sunday_second_from', true ); // Sunday Second From ?></li>
<li><?php echo get_post_meta( get_the_ID() , '_wpseo_opening_hours_sunday_second_to', true ); // Sunday Second To ?></li>
</ul>
<?php
$args = array(
'id' => 'all',
'width' => 300,
'height' => 300
);
echo wpseo_local_show_map( $args );
?>
<?php echo get_the_term_list( get_the_ID() , 'wpseo_locations_category', '<p>', ', ', '</p>' ); ?>
<?php endwhile; else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment