WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using WP rewrite rules for my custem arguments,
But when I am trying to generate permalink like this:

    'type' => 'foo',
    'paged' => 2,
),get_permalink($id)) ;

It returns still:


But I need to turn it into this:


Rewrite rules work perfectly, but "add_query_arg"..

How to solve?

share|improve this question
add_query_arg is for adding query string arguments, not for generating pretty permalinks. what context are you using this in exactly? have you already added your type query var and added a rewrite rule to handle incoming requests via add_rewrite_rule? – Milo Feb 6 '13 at 0:30
@Milo I added a few rules via "generate_rewrite_rules" action – Digerkam Feb 6 '13 at 0:38
up vote 0 down vote accepted

I'm affraid this "nasty" solution would be the most effective than trying to write some cool function that will translate your permalinks into pretty permalinks:

$permalink = rtrim( get_permalink( $id ), '/' ) . '/foo' . '/2';

The rtrim part (removing trailing slash) is just for to be sure there are not going to be two slashes on the end of the first part of your new pretty permalink.

share|improve this answer
The simple is the golden, you are right.. Sometimes it is effective doing it manually than building a framework in a framework :) – Digerkam Feb 6 '13 at 21:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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