The way I see it you have two options here:
- Pass the id to a custom template and then create a custom
wp_query
loop and use$_GET['id']
as the id of the loop.
For Example:
<?php
/*
Template Name: Pop Up View
*/
//get id from your url
$id=$_GET['id'];
//start custom loop
$query = new WP_Query( 'p=$id' );
//loop stuff and page template here
?>
then you would call <a href="https://wordpress.stackexchange.com/questions/76322/custom-item-template?id=<?php the_ID();?>">Link</a>
Or going more with your current code you could do something like
if ($_GET['custom-template'] == 1) {
get_template_part( 'custom-template');
die(); //or exit();
}
This fixed a few problems I see with your current code. One being that return can’t be used outside of functions. Also uses get_template_part instead of include with is a more WordPress way to do it.
Both ways should work, hopefully that gets you on the right track.