{"id":1232,"date":"2024-01-17T14:41:08","date_gmt":"2024-01-17T20:41:08","guid":{"rendered":"https:\/\/ma.rcbla.se\/blog\/?p=1232"},"modified":"2024-01-17T14:45:22","modified_gmt":"2024-01-17T20:45:22","slug":"issue-with-register_post_type-with-custom-capability-types","status":"publish","type":"post","link":"https:\/\/ma.rcbla.se\/blog\/2024\/01\/issue-with-register_post_type-with-custom-capability-types\/","title":{"rendered":"Issue with register_post_type with custom capability type(s)"},"content":{"rendered":"<p>I have a plugin for a site that creates multiple custom post types (CPT). Each with their own custom capability specified via the <code>capability_type<\/code> attribute of the <code>register_post_type()<\/code> function. I copy-and-pasted the code block for each <code>register_post_type()<\/code> from the first one, which includes the <code>capability_type<\/code> as an array, ie. <code>array('type' , 'types')<\/code>. Some of the subsequent CPT didn&#8217;t need multiple capability types so I was receiving the warning &#8216;Notice: Undefined offset: 1 in post.php&#8217; due to a single item in the array. The fix was to remove the array wrapping the single value, et voila, no more warning.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have a plugin for a site that creates multiple custom post types (CPT). Each with their own custom capability specified via the capability_type attribute of the register_post_type() function. I copy-and-pasted the code block for each register_post_type() from the first one, which includes the capability_type as an array, ie. array(&#8216;type&#8217; , &#8216;types&#8217;). Some of the [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,13],"tags":[],"class_list":["post-1232","post","type-post","status-publish","format-standard","hentry","category-coding","category-humor"],"_links":{"self":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts\/1232","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/comments?post=1232"}],"version-history":[{"count":6,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts\/1232\/revisions"}],"predecessor-version":[{"id":1238,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/posts\/1232\/revisions\/1238"}],"wp:attachment":[{"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/media?parent=1232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/categories?post=1232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ma.rcbla.se\/blog\/wp-json\/wp\/v2\/tags?post=1232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}