Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

How to add in the Tag URL with parameter WordPress


Wordpress version: 3.2.1.
I'd like to change the tag url from to<strong>new-car</strong>?gg=<strong>new-car</strong> - where new-car is the tag and it must be written 2 times to call the tag page results (first) and another part of the page with the query gg (second). Could you please help? Thanks

Answers (2)


Julio Potier answers:


Can you explain and show your other part of the page ?
Maybe we can find another kind of script to use the usual tag link ;)

Thank you

advalue comments:

the other part of the page contain a <?php include (.... ?> which call an xml file and the parameter gg shows the results of the query in the xml... I hope this helps. thanks

Julio Potier comments:

So i guess :
in your php script you get the value by <em>$_GET['gg']</em> ?
Why don't you try to parse it with explode <em>$_SERVER[SCRIPT_URI]</em> for example ?
function baw_parse_my_tag()
$parsed = parse_url( $_SERVER[ 'SCRIPT_URI' ] );
$parts_temp = explode ( '/', $parsed['path'] );
$perma_tag = '/' . $parts_temp[1];
$tag_temp = explode( '?', $parts_temp[2] ); // prevent bad url like
$tag = $tag_temp[0];
if( $perma_tag = get_option( 'tag_base' ) ) {
$url = $parsed['scheme'] . '://' . $parsed['host'] . $parsed['path'] . '?gg=' . $tag;
wp_redirect( $url, 301 );
if( !isset($_GET['gg'] ) ) {
add_action( 'init', 'baw_parse_my_tag' );

Code tested.

Julio Potier comments:

ps : i won't code more for $5. Sorry !


Mariano Pereyra answers:

The most important question here is, how are you going to build the URLs in links? IF you want to build them by hand no problem, but if you want WP to build them, there's where it gets complicated. You'll need to add a filter to intercept post links.

Letting WP accept parameters in the URLs is a rather simple task (If you know your way around WP using PHP)

Check out this page:

advalue comments:

I'd like to create url in automatic for each tag...
I'd like to use the parameter only in the tag page and in, if it is possible also for the category page...

Mariano Pereyra comments:

You'll need a pluguin for that (and there doesn't seem to be any, this is too specific).
For a start, WP is very picky about parameters (It discards anything it doesn't understand) and then you need the parameter to be added automatically (what means you need to post process the WP links)

advalue comments:

I found in wp-includes/category-template.php under the Tags section a function called "get_tag_link"... row 978... I think here I can add the parameter.... thanks