I've been searching the internet for 6 hours now, so I decided to ask this in the forum and would appreciate every help.

I just want my permalink to say (e.g. portfolio, post, etc)


I need the param, because the post itself defines the "whatever" parameter and there is a search form in the post, which initializes itself using this parameter (the searchform gets the parameter, if it's in URL). For single links, I could've placed the param into the link, but the WP defines the permalinks restrictively.

I tried adding add_query_arg() to functions.php without success (It's not even clear where to place the code (single.php or functions.php) and how to call the function from the post).

I then tried adding custom fields and Meta Boxes, but they seem to conatin the extra parameter but not add it to the URL. So all I get is:


a.) BEST SOLUTION The best way would be, to add a custom field to the post (or post type), which inserts a value the param and shows the permalink-URL with that parameter.

b.) JUDO SOLUTION The simplest thing would be, to add this parameter (text) to the link.

There are a gazillion post about this online, but they all refer to parsing of parameters which external links pass ($_GET) and conditionally change the appearance of the site or adding one specific parameter/value to each post/page. I do not need this.

Is there any way to add this 1 single parameter to the permalink-URL directly from the post, without changing 18 php files and writing hundred lines of code?

Thank you for any help!


PS. I am using WP 3.6.1 DE with inovado


Things I have already tried

  1. WP Codex add_query_arg()
  2. Stackoverflow: question 4586835 how-to-pass-extra-variables-in-url-with-wordpress
  3. Cookie-monster: wordpress-url-parameter-utility
  4. Creativebloq: user-friendly-custom-fields-meta-boxes-wordpress-5113004
  5. Farinspace: how-to-create-custom-wordpress-meta-box
  6. stackexchange.com: questions 51444 - add-extra-parameters-after-permalink

and finally

  1. webopius: using-custom-url-parameters-in-wordpress
  • Forgot to say: the form is defined elsewhere, is generic. (formidable) Oct 1, 2013 at 15:01

2 Answers 2


The Codex page for post_link has an example similar to what you need. For custom post types, there's also the post_type_link filter.

This would go in your theme's functions.php, and checks if a meta key query_arg exists, and appends it to the URL if so:

function wpa_post_link( $url, $post ){
    if ( $meta = get_post_meta( $post->ID, 'query_arg', true ) ) {
        $url = add_query_arg( 'param', $meta, $url );
    return $url;
add_filter( 'post_link', 'wpa_post_link', 10, 2 );

I don't know if I understood your question correctly, but ...

<a href="'. get_the_permalink($post->ID) . '?extraParam=xxx' .'">

Something like that is not enough?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.