• I’m modifying the default “post” type and I found a problem (and a workaround). I expected this to work:

    register_post_type('post',get_post_type_object('post'));

    Problem is, inside the code (wp-includes/post.php) in some places it expects $object->labels to be an object and in other places it expects $object->labels to be an array.

    This workaround did it for me:

    $object = get_post_type_object('post');
    $object->labels = (array) $object->labels;
    register_post_type('post',$object);

    (Obviously, the above is a no-op. I modified $object->labels in my own code.)

    Please let me know if I’m going about this the wrong way. I’ll leave it to someone more familiar with the code to decide whether or not this is a bug. (Unfortunately, it seems that there are already public interfaces that rely on this inconsistency.)

  • The topic ‘register_post_type() vs. get_post_type_object()’ is closed to new replies.