Url rewrite on index.php?term=[term_name]

Question

Im having some troubles with Url rewrite …

I have a Custom Post Type with an custom taxonomy… I would like to when visiting the url [ site_url ] /[ custom post type slug ]/[ term_slug ] to redirect the newest CPT post with that term attached. at the moment when i visited the link i redirects me to the oldest post ( the one with the lowest post_id) with that term..I know that i have to get some sort of ‘pre_get_post’-filter on the that "url" before it redirects to the oldeste post.. but I can’t figure out how…

At the moment I only have this

function TermRules() {
add_rewrite_rule( "hitlister/(-.+)?$", "index.php?term=$matches[1]&post_type=chart", "top" ); }

Anyone that can help me

0
Rasmus Pedersen 1 month 0 Answers 22 views 0

Leave an answer