I'm trying to extract a custom variable (utm_campaign) from the URL and echo it out. I've added the following in functions.php, but it works only when I'm logged in as the admin.
add_filter( 'query_vars', 'add_query_vars_filter' );
function add_query_vars_filter( $vars ){
$vars[] = "utm_campaign";
return $vars;
}
And in my index.php file, I have this at the top:
if(isset($wp_query->query_vars['utm_campaign'])) {
$campaignName = $wp_query->query_vars['utm_campaign'];
echo $campaignName;
}
Someone suggested to turn define('WP_CACHE', true) to false in wp-config.php which I have done, but it still didn't fix the issue.
What am I doing wrong?
Thanks in advance.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire