Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

something very strange is going on with a WP theme I'm developing. The set of default rewrite rules regarding attachments


have simply disappeared from my rewrite rules! I checked $wp_rewrite->rules and with "Rewrite Rules Inspector" plugin... they're nowere to be found, and now every attachment URL gives a 404 error.

I can't figure our what I did to delete them, since I'm not messing with custom rewrite rules and I have only one custom post type which is called "userdata" and it has nothing to do with attachments. And I can't figure a way to get them back. I've tried flushing, disabling every plugin, temporarily changing the theme to see if I was somehow overwriting them somewhere. I even tried to empty the rewrite_rules record in wp_options table.... no effects.

In your opinion, what could have caused this, and (more important) what can I do to get these rules back? Thanks for your help...

-- EDIT --

Reading this question i see that wp_insert_post breaked category and tag rewrite rules. This is similar to my question since I use wp_insert_attachment inside my theme and the attachment rules were deleted. But the main difference is that unfortunately I couldn't make them appear again, even flushing the rules :( Any idea? Thanks

share|improve this question
Can you post relevant code? In particular, your wp_insert_attachment & your custom post type registration. –  TheDeadMedic Jul 12 '13 at 4:37
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.