WordPress.org

Ready to get started?Download WordPress

Forums

CPT-onomies: Using Custom Post Types as Taxonomies
[resolved] custom post-type triggers error in wp-includes/post.php (2 posts)

  1. JuniperPaul
    Member
    Posted 1 year ago #

    After I used CPT-onomies to create this custom post type, the following error appears at the top of every page both on the displayed site and in the admin interface:

    Notice: Undefined offset: 1 in /[...]/wp-includes/post.php on line 1155

    which points to:

    1154	// Singular base for meta capabilities, plural base for primitive capabilities.
    1155	list( $singular_base, $plural_base ) = $args->capability_type;

    This error message goes away if I deactivate CPT-onomies. (I deactivated all other installed plugins, so the problem appears to be solely between CPT-onomies and WordPress 3.4.2.)

    Please let me know if you see something to tweak either in your plugin or in my CPT definition to work around this problem.

    Thanks!
    Paul

    http://wordpress.org/extend/plugins/cpt-onomies/

  2. Rachel Carden
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Paul!

    This is actually a bug with the "Capability Type" setting which I've already taken care of for the next version, which should hopefully be out within the next week. But if you want to go ahead and patch it up, here's what you do:

    Open up 'admin-settings.php' and find the following lines, somewhere around 288:

    if ( isset( $cpt[ 'capability_type' ] ) && !empty( $cpt[ 'capability_type' ] ) ) {
       // can be separated by space or comma
       $cpt[ 'capability_type' ] = str_replace( ', ', ',', trim( $cpt[ 'capability_type' ] ) );
       $cpt[ 'capability_type' ] = str_replace( ' ', ',', trim( $cpt[ 'capability_type' ] ) );
       $cpt[ 'capability_type' ] = explode( ',', $cpt[ 'capability_type' ] );
    }

    and replace it with:

    if ( isset( $cpt[ 'capability_type' ] ) && !empty( $cpt[ 'capability_type' ] ) ) {
       // can be separated by space or comma
       $cpt[ 'capability_type' ] = str_replace( ', ', ',', trim( $cpt[ 'capability_type' ] ) );
       $cpt[ 'capability_type' ] = str_replace( ' ', ',', trim( $cpt[ 'capability_type' ] ) );
       $cpt[ 'capability_type' ] = explode( ',', $cpt[ 'capability_type' ] );
       // only save as array if more than one capability type
       if ( count( $cpt[ 'capability_type' ] ) < 2 ) {
          if ( count( $cpt[ 'capability_type' ] ) == 1 )
             $cpt[ 'capability_type' ] = array_shift( $cpt[ 'capability_type' ] );
          else
             $cpt[ 'capability_type' ] = NULL;
       }
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.