Using WordPress rewrite rules
-
Hi all,
This is driving me insane! Hope someone experienced will help me with this. I don’t have a lot of experienced in WordPress. I have read many articles and threads in other forums, I think posting here might speed up things.
I am trying to write a pdf plugin for a site that should return a pdf file for a post when the post url has /format/pdf at the end, such that:
http://worksheets.mathematicsi.com/indices-worksheet/format/pdf
…for example returns;
http://worksheets.mathematicsi.com/indices-worksheet/?format=pdf
I almost did it but each time I visit the url ( POST/format/pdf ) WordPress redirects to the post url instead. I was wondering whether someone might help me with a proper code. It is very simple but I don’t know how WordPress executes everything in the background. I also tried: remove_filter(‘template_redirect’, ‘redirect_canonical’); but that returns a 404 error.
I am fine with other functions of the project it is just getting the rewrite rule POST/format/pdf to point to: POST/?format=pdf
I also tried to get the rewrite rule variable/’query’ but was unable to. I think I can’t just use $_GET, I have to register them.
Thanks.
The topic ‘Using WordPress rewrite rules’ is closed to new replies.