Passing custom _GET query into custom template
-
I have a custom page that I want to pass a custom variable “player” into the page to populate an Iframe URL to get user statistics from an external source, I found this as my guidelines, But It’s not picking up anything I put as /?player=username only the fallback username “playerusername” in this case.
http://codex.wordpress.org/Function_Reference/get_query_var
This is my page source:
<?php /* Template Name: PlayerStats */ ?> <?php get_header(); ?> <?php function add_query_vars_filter( $vars ){ $vars[] = "player"; return $vars; } add_filter( 'query_vars', 'add_query_vars_filter' ); ?> <div id="content"> <?php if(have_posts()) while(have_posts()) : the_post(); ?> <div id="post-<?php the_ID(); ?>" class="entry"> <h1 class="title"><?php the_title(); ?></h1> <div class="content"> <?php $player = (get_query_var('player')) ? get_query_var('player') : playerusername; ?> <h2>Viewing Player <?php echo $player; ?></h2> <iframe src="http://subdomain.website.com/single_player.php?p=<?php echo $player; ?>" width="100%" height="1200" scrolling="no" class="iframe-class" frameborder="0"></iframe><br /> <?php the_content(); ?> <?php wp_link_pages(array('before' => '<div class="page-link">'.__('Pages', 'cpotheme').':', 'after' => '</div>')); ?> </div> </div> <?php endwhile; ?> </div> <?php get_sidebar(); ?>The blog I need help with is: (visible only to logged in users)
-
The site you are asking about does not seem to be hosted on WordPress.COM so you need to make friends over at WordPress.ORG the keepers of the software you are using.
This site is for support of sites hosted on WordPress.COM. You should address your questions to WordPress.ORG the keepers of the software you are using: http://wordpress.org/support/
The forum at WordPress.ORG is not connected to WordPress.COM so you will need to open an account at .ORG if you do not already have one. You may use the same email at WordPress.ORG as you do at WordPress.COM.
For more on the difference: http://support.wordpress.com/com-vs-org/
-
Yep, Already done that made, they seem a little inactive and im trying to find a quick answer.
-
This forum is for WordPress.com who do not have access to modify PHP files like the one you are asking about, so the forums auxclass linked http://wordpress.org/support/ really are the right place to post.
You should keep in mind that WordPress is free, open source software, and those forums are volunteer-based. If you’re having trouble getting fast responses, you may want to consider hiring help instead of relying on volunteer-based forums.
I did look at your example quickly, and I’m not sure why it wouldn’t work. It might help to post a live example if possible (if you don’t have a test site, consider making one) because the first thing I would want to do is check the page that has the iframe to see of the variable is getting printed properly there. You might also try hard coding in the _GET variable as a test to make sure that part works as expected when you’re certain it has a value.
For further help, you should try to include even more detail (i.e. a live test link) and then wait for help from the volunteer-based forums at http://wordpress.org/support/
- The topic ‘Passing custom _GET query into custom template’ is closed to new replies.