New tag in add_permastruct doesn’t appear in query_vars
-
Hi all,
I’m absolutely baffled as to why this isn’t working. I think I must be missing something. I’m trying to add an alphabetical list of authors to a site with lots of contributors. I’d like this to work like:
/archive/authors/A (list all authors with surname starting with A
/archive/authors/B
etcI have implemented all the code for listing authors etc as a page template, which all seems to work fine. In order to make the url structure work, I’ve added some rules/tags:
add_rewrite_rule('archive/authors/([A-Z]{1})/$', 'index.php?pagename=authors&author_letter=$matches[1]', 'top'); add_rewrite_tag('%author_letter%', '[A-Z]{1}', 'author_letter='); $wp_rewrite->add_permastruct('author_archive', '%pagename%/%author_letter%'); $wp_rewrite->flush_rules();
This URL rewrite mostly works — you arrive on the correct page when you visit a URL — but the author_letter variable doesn’t show up in $wp_query->query_vars.
I’d really like to do this properly, but I’m on the verge of fixing this with a hack — I just can’t get it to work. Any ideas?
- The topic ‘New tag in add_permastruct doesn’t appear in query_vars’ is closed to new replies.