WP Rewrite Rules giving 404 error after working for a while
-
Hello Reader,
I’m working on url rewriting for which i used the below code;
function custom_add_rewrite_rule(){ $posts = get_posts( array( 'numberposts' => -1, 'post_type' => 'post') ); if( $posts ){ foreach($posts as $post ){ add_rewrite_rule( $post->post_name . '/download/?$', 'index.php?name=' . $post->post_name . '&post_action=download&post_id=' . $post->ID, 'top' ); } } } add_action('init', 'custom_add_rewrite_rule');
above code working fine but the problem is that after working for hours it start giving 404 error and then i have to do Permallink save to make it work. I tried flushing rewrite rules on post update this isn’t a permanent solution.
Anyone can guide me how can i shout-out this permanently.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘WP Rewrite Rules giving 404 error after working for a while’ is closed to new replies.