Changing a custom post type “has_archive” after registered


Ok, I’ve seen some similar posts on how to change a custom post type’s attributes after it has been registered (in my case, I’m trying to modify a custom post type created by a plugin without modifying the plugin files).

This appears to be working for some properties:

function change_wp_object() {
  $object = get_post_type_object('easy-rooms');
  $object->show_in_menu = true;

However, I can’t seem to get has_archive to change – and it appears to be related to the permalinks. I’m guessing a new rule for /easy-rooms/ isn’t being added.

I’ve tried adding flush_rewrite_rules() (even though it’s a bad idea to run it at init) but even that doesn’t work. Post type is set to public and if I do change the has_archive in the plugin code it does work.

Any ideas? Thanks in advance!

, , Dinis Correia 10 years 2013-07-16T18:51:09-05:00 0 Answers 99 views 0

Leave an answer