• 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;
    }
    add_action('init','change_wp_object');

    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!

  • The topic ‘Changing a custom post type “has_archive” after registered’ is closed to new replies.