Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.