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 working on a plugin where I am trying to create a "archive like" page with permalinks.

Here is what I have so far:

  1. I've created a query var "experience"
  2. I've created custom SQL selects using - "post_join" and "post_where" hooks

  3. I've created a custom template using the "template_redirect" hook

  4. I've added custom permalink rules and flushed them

All good so far, the only thing I'm not getting is how I can link to my new archive like page "dynamically".

I can create a static link like mysite.com/experience/id - but this will not work when permalinks are off.

Also I tried to generate the URL like

<a href="' . add_query_arg( 'experience', $id, get_bloginfo('url') ) . '">url</a>

This works when permalinks ar off and also when on, but this not changes to mysite.com/experience/id when they are on. It always remain mysite.com/?experience=id

So what I would like to understand is how can I create those permalinks dynamically, so they will be recognized depending if permalinks are on/off.

Thank you.

share|improve this question
up vote 1 down vote accepted

Just write a function that checks if permalinks are on by checking whether get_option( 'permalink_structure' ) is empty or false and generates the appropriate link given the $id.

Something along the lines of the get_permalink() function which either looks at the $post global or looks at the $id passed into it.

share|improve this answer

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.