I have researched numerous posts and tutorials about this and have gotten most of it to work. But when I test if( isset( $wp_query->query_vars[‘speaker’] )) it is not. Any ideas why it is not being set? I found one post where someone asked a very similar question, but hasn’t yet received an answer.

From my theme’s functions.php:

function create_new_url_querystring()
{
add_rewrite_rule(
    '^speaker/([^/]*)$',
    'index.php?pagename=author-profile&speaker=$matches[1]',
    'top'
);
add_rewrite_tag('%speaker%','([^/]*)');
}

add_action(‘init’, ‘create_new_url_querystring’);

From my custom page template:

if( isset( $wp_query->query_vars['speaker'] )) {
echo"speaker is set";
}
else
{
echo"speaker is not set";
}

www.mydomain.com/speaker/194/ does get me to my template page, but it outputs “speaker is not set” and I can’t access the value 194 (in this example) from the url. Did I leave out a step somewhere? Thanks!

Read more here: URL rewriting wordpress $wp_query->query_vars not set


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , ,

Wordpress related questions and answers: