After some more Googling…
New single.php looks like this:
<?php
get_header();
global $wp_query;
if ( ! isset( $wp_query->query_vars['map'] ) )
{
if (have_posts()) :
while (have_posts()) :
the_post();
the_title();
the_content();
endwhile;
endif;
?>
<p><a href="https://wordpress.stackexchange.com/questions/31442/<?php echo get_permalink(); ?>?map=yes">Map</a></p>
<?php
}
else {
?>
<div id="map-canvas"></div>
<?php
}
get_footer();
And functions.php like this:
add_filter('query_vars', 'parameter_queryvars' );
function parameter_queryvars( $qvars )
{
$qvars[] = 'map';
return $qvars;
}
The function tells WordPress to expect a variable ‘map’ in the query string and single.php checks if a map variable has been set/passed via the referring page.
Hope this helps someone.
Related Posts:
- Is it possible to use a single custom post as the site front page
- Listing a post’s categories and subcategories
- Single post comment template not working
- How do I show google ads between post content?
- Add inline style to get_the_category_list
- Help with figuring out the future post workaround
- Disable single view for specific post category
- Only nextpagelink on wp_link_pages
- How To Pass Current Post Type ID from Single Template To Custom Page Template
- Is it possible to create rel=”noindex, nofollow” for a single post if contain bad keywords?
- Custom seperate Single.php
- Set a cookie only in single posts
- Custom post type not respecting template hierarchy
- diffrent style for post single page
- WordPress object for comments frame [closed]
- I’m having a problem viewing the Youtube video
- Use different «Single.php» for custom categories
- force https except one page/post
- Single custom post type template not working (single-custom_post_template.php) not working
- Single.php category entries not showing right colours
- Link from archive-page.php to single-page.php
- How to check if a post is in categories x,y,z inludint their subcategories
- Changing the display of the themename_posted_on() function
- How to Highlight current category on category and single page template?
- Exclude single page from function
- WordPress, alternative single post template
- get full real path of thumbnail post img wordpress
- how to loop through this in blog single?
- Modify post template on Divi Theme
- I want to signin from first wordpress site to other wordpress website without registration..without using network mode
- Try to showing product file size on product single page
- Improve related posts
- Get active term on single (CPT) page
- Having single posts appear under the blog homepage and highlight menu items properly?
- Single.php loading fully on localhost but not on server
- explain why is_single doesn’t work
- function updateMap for Google Maps API
- Type error: cannot convert the series to
- ApiNotActivatedMapError for simple html page using google-places-api
- How to check if the product is in a certain category on a single-product.php in Woocommerce?
- How to query posts based on lat-lng coordinate as post meta?
- Custom Single Post By Category
- Pre get posts for single post
- Pull Two Posts Into Custom Post Type `single-cpt.php`
- is_singular() not working if called via callback function of admin-ajax.php
- Proper way to load a single post via Ajax?
- Problem getting single_template filter to work – I want to serve a different single.php file for posts in a certain category
- Post Rank on Single Post page based on custom field
- Geocoding an Exploded Custom Field Array
- Displaying Meta Box Image
- How to get category id in single.php wordpress?
- Google Maps and Yandex Maps doesn’t work correctly
- custom single.php not working
- Google Maps in WordPress
- How to call custom single post?
- WP Query Category Atribute Not Working
- Google maps causing mixed content in header
- changing permalink for custom template in posts of a certain category
- Display all posts that were published before full post on single.php
- how to get the categories for a single product in a hierarchical way
- Programmatically rewriting slug through functions.php but returns 404
- Refresh Markercluster after ajax call
- How to add multiple markers on the google map, at a certain meta_key and meta_value
- Insert sometext after first h3 in content
- Cannot retieve the_content() and the_author() – both returning empty strings
- Get term name without a foreach loop
- Including all post id’s of a custom post type into an array
- Is it possible to customize the post according to post format in single.php?
- get_term_link is Ending to single.php
- Post type no single page
- get_previous_post() while accounting for sticky posts
- adding custom post type “name” to single template
- Highlight archive link on single.php
- Integrating WordPress with Your Website
- Using custom post types WordPress network
- Load more posts (Ajax) in tabbed sidebar on single.php
- Can I style single post that are in multiple catergories?
- Show single post child category from a determined parent
- My single.php page skips the first div tag
- Insert Google Maps HTML in WordPress
- Filtering markers on google map by WordPress category[SOLVED]
- Add custom field information to source meta data
- display multiple posts and posts content on a single URL
- How to adjust Related Page Thumb Sizes on single page?
- When category name and title are the same … WP will select archive.php instead of single.php
- Advanced Custom Fields – Google Map Won’t Render Unless Variable Dumped
- How to set up a single product shop with woocommerce? Skipping the product archive
- Single Page of Custom Post Type Not Showing the Content Of post
- Load next post by ID on a single page
- Display Taxonomy Term for CPT on single-CPT.php
- How to Fix Custom WordPress Loop with Pagination on Single Post View?
- Querying latitude and longitude into google maps correctly
- different single.php for different page templates
- Post Thumbnail on Single (if elseif else)
- Parent for a single (single.php)
- How do I get a single page navigation depending on the previous page?
- How to grab data (titles, thumbnails and custom fields) from multiple posts to populate a new array efficiently?
- Get Child Custom Post Content on Single.php?
- Wrap div-tag around posts in page
- How to get the featured image inside of a single-.php template?