Rewrite post type into a page with year filter
Rewrite post type into a page with year filter
Rewrite post type into a page with year filter
Overcoming a complex WordPress page rewrite rules request
Try adding a query var add_filter(‘query_vars’, ‘foo_my_query_vars’); function foo_my_query_vars($vars){ $vars[] = ‘question’; return $vars; }
custom rewrite rules will not be added to wordpress rewrite_rules database
I think you should do something like this: function my_rewrite_rule() { add_rewrite_rule(‘^prefix/section/([0-9]+)/([^/]*)?’, ‘index.php?section=$matches[1]&name=$matches[2]&post_type=post’, ‘top’); } add_action(‘init’, ‘my_rewrite_rule’); Add a query var for section: function my_query_vars( $vars ) { $vars[] = ‘section’; return $vars; } add_action( ‘query_vars’, ‘my_query_vars’ ); I created the pattern for your section (which can be 1 or 2) and used $matches[2] to … Read more
After lots of pulling my hair out I figured out the problem. I needed to use the add_rewrite_tag() function to tell wordpress to allow my query vars. function prefix_movie_rewrite_rule() { add_rewrite_tag(‘%state_id%’, ‘([A-Za-z0-9\-\_]+)’); add_rewrite_tag(‘%state%’, ‘([A-Za-z0-9\-\_]+)’); add_rewrite_rule ( ‘states/([A-Za-z0-9\-\_]+)/([A-Za-z0-9\-\_]+)’, ‘index.php? state_id=$matches[1]&state=$matches[2]’, ‘top’ ); } add_action( ‘init’, ‘prefix_movie_rewrite_rule’);
Homepage rewrite rule
Problem with rules occurs, because rule for a given projecttype is added when you visit relevant URL. Every time you visit one of projects/{projectstype}/ addresses and flush rewrite rules, they are deleted and only one rule (only for current project type) is saved/created. You can add your code to request filter hook, then there is … Read more
The reason the rewrite rules wont work is because you’ll find that if you look at your .htaccess file, WordPress doesn’t actually load if the file that is being requested is present on-disk. So if they try to access an image file, because it’s there, on disk, WordPress isn’t loaded and so the rewrite rules … Read more
get_author_posts_url() doesn’t return the author URL, because of wrong author_structure