Tag Info

New answers tagged

0

The problem with calling flush_rewrite_rules() is that the rules instantly get regenerated, while your plugin's hooks are still active. What I usually do, because it's the simplest route to success, is delete the rewrite_rules option on activation/deactivation. The rules will then get regenerated on the next pageload instead of the current one: ...


0

As I understand your Question, you need to hook into most of the Link Filters (which are listed here: http://codex.wordpress.org/Plugin_API/Filter_Reference#Link_Filters ) and then add the query to them if the queryvar "clean" is set. Happy Coding, Kuchenundkakao


0

Ok, resolved this. I am now registering the taxonomy and terms on the init hook rather than wp_loaded and that seems to have fixed things. I will accept this answer as soon as I can.


0

Finally figured it out. 1) I was calling the first function at 'rewrite_rules_array' instead of 'init' which was just dumb. 2) There was still something wrong with it, but I explored another area that seems obvious now, but which I originally glossed over because it seemed to be. https://codex.wordpress.org/Rewrite_API/add_rewrite_endpoint ...


1

You can create a posts archive by just setting post_type=post in your rewrite rule: function custom_archive_rule() { add_rewrite_rule( 'custom-archive/?', 'index.php?post_type=post', 'top' ); } add_action( 'init', 'custom_archive_rule' ); WordPress will identify this as is_home, so you'll have to target it in pre_get_posts ...


0

Thanks @cybmeta for your hint. I searched my theme and found an other flush_rewrite_rules(true); on the init hook. I removed this and now the rule is being remembered. Seemingly, calling the function twice is breaking something. Doesn't really make sense to me, but it works now, so whatever :)


1

It wouldn't work too smoothly since you are mixing "one of a thing" (which in WP usually means single post) and "many of a thing" (post or term archive). Since comments are engineered to work with posts (pages are also kind of a post), the closest to this you can easily get is probably creating hierarchical Custom Post Type for this. Then /cars would be ...


0

I'll preface this by saying I think it makes much more sense to have play appended to the end of the permalink, which you could easily achieve with add_rewrite_endpoint, but in the interest of answering the question as it was asked... First you'll need to add a query var that you'll later check to know when to load your other template: function ...



Top 50 recent answers are included