Help w/custom query variable and rewrite/permalink
-
I am working on something very similar to TheMarco’s problem. Sadly, I’m not yet WordPress-proficient-enough to adapt it to my situation. Hoping you can help.
What I have:
A site of quotes with format: “Quote text.” -Quote Author
See quotup.com for my test website (my apologies in advance for the testing-profanity).
What I’m after:
Clicking “-Quote Author” should launch a page of all quotes by that quote author with URL: https://example.com/SteveStevenson, where Steve Stevenson is the Quote Author.
What I’ve done:
Created a custom table called wp_qauthor that is tied to wp_posts by post_meta (qauthor_id).
Added the following code to functions.php (thanks, Otto):add_filter('query_vars', 'add_my_var'); function add_my_var($public_query_vars) { $public_query_vars[] = 'qaid'; return $public_query_vars; }
Created a link for the Quote Author’s name as such:
<a href="https://example.com?qaid=2>Steve Stevenson</a>
Clicking on this link currently loads home.php, but I need it to hit index.php, where I’ve added the code:elseif (get_query_var('qaid')) { $qaid = get_query_var('qaid'); query_posts($query_string . "&meta_key=qauthor_id&meta_value=" . $qaid);
Assuming I need to add some wp_rewrite rules as well to functions.php, but we all know what assuming does.
At this point, a single response would be absolutely A+, as I’m frustrated as all gitup. Many thanks.
- The topic ‘Help w/custom query variable and rewrite/permalink’ is closed to new replies.