New answers tagged add-rewrite-rule
There are a few things to sort out here. The first is why your rewrite rule will not work. add_rewrite_rule('/api', '/wp-admin/admin-ajax.php', 'top'); The WordPress rewrite does not redirect to a page. What does is it parses the path using regular expressions into a WordPress query vars. If you disable pretty URLs in WordPress, you'll see the query vars ...
Before asking any question here, please try to find it out yourself. In case of wordpress you should look at http://codex.wordpress.org/ first. Most of the answers are available already. The piece of code you are looking for is a function flush_rewrite_rules(). Ref: Rewrite Rules
It looks like you need to add your news custom post type to the query for archive pages (I had the same problem). Codex: custom post types to query Add this code to your functions // Show posts of 'post', and 'news' post types on archive page add_action( 'pre_get_posts', 'add_my_post_types_to_query' ); function add_my_post_types_to_query( $query ) ...
My recommendation is to register a custom post type. You can call it products, and then all posts placed under Products will get the http://domain.com/products/some-product rewrite. Once it's its own post type, you can specify a custom template for it, single-product.php, and you can add any custom fields, classes, etc. from there.
Consider my answer just as an alternative. I developed a plugin, Clever Rules, that allow to specify a route, a query and (among other things) a specific template. What you need using Clever Rules is register a rule, but please note that with current version you can register rules only in plugins, not in themes. Download Clever Rules, activate it. Now you ...
Top 50 recent answers are included