Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a single post page that contains an audio player. I need place a link on the page that will open up the player in a pop up window. Simple right?

My thoughts were that I have an additional link using the_permalink open the post in a new window and just limit the loop to that new audio player.

My question is how do I control what template the link (the_permalink) grabs? I'm familiar with the wordpress template hierarchy, and I don't want the permalink to grab single.php, instead i'd like it to grab pop-up-player.php template.

Any idea how to do this?

I've googled and searched stack exchange but can't seem to find anything related to what I'm trying to do.

share|improve this question

1 Answer 1

Why not make your link include a parameter to change the way it loads the single.php page?

<a href="<?php the_permalink(); ?>?audio-popup=1">Link</a>

Then in the single.php, you can do something like if ($_GET['audio-popup'] == 1) { include popup-player.php; return; } or similar to make it load that popup-player template instead.

There's other ways, but this is probably the simplest and suitable for a custom site. If you were doing this in a more generic theme way, then I'd say to set up query vars and rewrites and such, but for a one-off, you don't need that sort of thing.

share|improve this answer
    
Hi otto, Why would I change the way it loads the single.php page? The popup will allow the audio to play while the user browses the rest of the site. I tried your solution and all it seems to do is append something to the URL and nothing else. –  nikibrown Aug 4 '11 at 21:57
    
Thanks for the answer though! –  nikibrown Aug 4 '11 at 21:58
    
You're missing that it's a two part solution though. See, the first part adds the bit to the URL. The second part would go into your single.php page, and when it detects that extra bit in the URL, it would load the popup-player.php page instead of displaying the rest of the single.php page. See, you'd put that IF code at the top of single.php. –  Otto Aug 4 '11 at 21:59
    
Hi Otto, I did place that at the top of my single.php file and it seems to be loading a different template but not the template I've specified. I had something mis-spelled earlier so all I saw was the new URL - apologies for that. –  nikibrown Aug 4 '11 at 22:13
    
I should also note that this link is on the single.php page itself, below the audio player. –  nikibrown Aug 4 '11 at 22:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.