Get new variable from permalink
-
Hi people!
I need to get a variable appended to the permalink, that should be in a post or custom post type.
No problem getting it when permalink are disabled, this is the code I’m using:
function add_query_vars($public_query_vars) { $public_query_vars[] = 'fruits'; return $public_query_vars; }
then I get using
get_query_var('fruits')
The problem is with enabled permalinks.
Using:
add_filter('rewrite_rules_array','mycode_add_rewrite_rules'); function mycode_add_rewrite_rules($rules){ add_rewrite_tag('%fruits%','([^&]+)'); add_rewrite_rule('^([^/]+)/([^/]+)/([^/]+)/?','index.php?pagename=$matches[2]&fruits=$matches[3]','top'); }
I cannot get the variable, then never occurs again 404 error when I add one or more “/” (ex. https://www.site.com/2012/06/title/first/second/third/)
Could somebody help me resolving this?
Thanks ??
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Get new variable from permalink’ is closed to new replies.