Forums

Custom querys broken? ($_Get variables -> Custom_Archives) (4 posts)

  1. jwheeler91
    Member
    Posted 6 months ago #

    I'm trying to get $_Get style variable on my permalinks of just one page. It's the live events page.

    So I want links like "http://strawsmusic.loc/live/?event=1330232400" but they just get converted to "http://strawsmusic.loc/live/".

    I followed these steps in the codex, but they don't seem to work?
    http://codex.wordpress.org/Custom_Queries#Custom_Archives

    I should mention that I am running wordpress in MAMP. I tried it with Twenty Eleven to see if it was my theme, but I guess not...

    Here is the code I added to functions.php

    add_filter('query_vars', 'event_queryvars');
    function event_queryvars($qvars) {
      $qvars[] = 'event';
      return $qvars;
    }

    And in the relevant template file:

    global $wp_query;
    if (isset($wp_query->query_vars['event'])) {
    	$event = esc_attr($wp_query->query_vars['event']);
    }
  2. jwheeler91
    Member
    Posted 6 months ago #

    Edit: With a bit more testing, I have discovered that the variable is picked up at the root web address so: http://strawsmusic.loc/?event=1330232400 works (kinda).

    But this isn't useful for me. I want it linked to the "/live/" page...

    So when i add the code to my events.php template,

    global $wp_query;
    if (isset($wp_query->query_vars['event'])) {
    	$event = esc_attr($wp_query->query_vars['event']);
    	echo $event;
    }

    So it doesn't work to use "/live/?event=1330232400"

  3. Andrew Nacin
    WordPress Dev
    Posted 5 months ago #

    Moving to "Plugins and Hacks." This is a question about canonical redirects, query variables, and such, not about 3.3 beta or RC.

  4. jwheeler91
    Member
    Posted 5 months ago #

    You can close it if you like,

    While I'd still like an answer, I found an alternative using Div IDs, JavaScript and adding # with event id to the url.

    its not ideal as the client has to be served more information then needed (which would otherwise be handled and shortened by the server...

Reply

You must log in to post.

About this Topic