wpmetabox / mb-custom-post-type Goto Github PK
View Code? Open in Web Editor NEWCreate and manage custom post types with easy-to-use interface in WordPress.
Home Page: https://metabox.io/plugins/custom-post-type/
Create and manage custom post types with easy-to-use interface in WordPress.
Home Page: https://metabox.io/plugins/custom-post-type/
I'd like to be able to have taxonomies with the rewrite option set so that urls like /customslug/category/subcategory/subcategory/postname are possible.
eg.
'rewrite' => array(
'slug' => 'customslug',
'hierarchical' => true
)
Might be related to #8, but it doesn't specifically mention custom taxonomies.
It would be great if you could add a setting ore even a hook that would allow to hide this post type conditionally,
For example i love your plugin and use it regularly but all my site are for customers that i don't want to see/play with the settings so i would make it only visible to my username.
Is this able to handle rewriting correctly?
Working only for the first level: /post_type/child
Doesn't work: /post_type/child/grandchild
I think we should create 2 meta boxes for:
These meta boxes are hidden by default, and when click Advanced button, they will be shown.
When seeking help with this issue, you may be asked for some of the following information:
WordPress version 5.8.2
Current theme: Oshin Child (version 6.5.1536925382)
Current plugin: MB Custom Post Types & Custom Taxonomies (version 2.3.0)
PHP version 7.4.26
An error of type E_ERROR was caused in line 29 of the file /var/www/vhosts/{ website }/httpdocs/wp-content/plugins/mb-custom-post-type/mb-custom-post-type.php. Error message: Uncaught Error: Class 'MBCPT\PostTypeRegister' not found in /var/www/vhosts/{ website }/httpdocs/wp-content/plugins/mb-custom-post-type/mb-custom-post-type.php:29
Stack trace:
#0 /var/www/vhosts/{ website }/httpdocs/wp/wp-includes/class-wp-hook.php(303): mb_cpt_load()
#1 /var/www/vhosts/{ website }/httpdocs/wp/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters()
#2 /var/www/vhosts/{ website }/httpdocs/wp/wp-includes/plugin.php(470): WP_Hook->do_action()
#3 /var/www/vhosts/{ website }/httpdocs/wp/wp-settings.php(578): do_action()
#4 /var/www/vhosts/{ website }/httpdocs/wp/wp-config.php(131): require_once('/var/www/vhosts...')
#5 /var/www/vhosts/{ website }/httpdocs/wp/wp-load.php(50): require_once('/var/www/vhosts...')
#6 /var/www/vhosts/{ website }/httpdocs/wp/wp-login.php(12): require('/var/www/vhosts...')
#7 {main}
thrown
Flush rewrite rules only when:
mb-post-type
(maybe not needed because the post type is used internally)Thanks for this extension, I want to make the following contribution (without Git Pull request):
I needed an option to allow to control the "prepend permalink structure" flag on the Custom Post Type registratiopn, and with a few code lines it seems to be added easily.
Maybe this can be included in a future update, as I think it will be a valuable addition to this and for others:
Thanks.
Don't use short codes. We need to add all labels for mb-post-type
which allows users to translate the plugin.
Also disable rewrite rule for mb-post-type
. See #2.
Undefined index: post_types | wp-content/plugins/mb-custom-post-type/inc/taxonomy/register.php:57
I would like to add categories and tags support to the custom post types that are setup through this plugin. Below is my response to a support topic on wordpress.org for this request. The support topic can be viewed here: https://wordpress.org/support/topic/categories-support?replies=4
If you add the following code to your theme's functions.php, a new meta beta will appear when creating a custom post type:
function cpt_support_for_cats_and_tags_meta_boxes( $meta_boxes ) { // Taxonomies $args_prefix = 'args_'; $meta_boxes[] = array( 'id' => 'taxonomies', 'title' => __( 'Supports Categories/Tags', 'mb-custom-post-type' ), 'pages' => array( 'mb-post-type' ), 'priority' => 'low', 'context' => 'side', 'fields' => array( array( 'id' => $args_prefix . 'taxonomies', 'type' => 'checkbox_list', 'options' => array( 'category' => __( 'Categories', 'mb-custom-post-type' ), 'post_tag' => __( 'Tags', 'mb-custom-post-type' ), ), ), ), ); return $meta_boxes; } add_filter( 'rwmb_meta_boxes', 'cpt_support_for_cats_and_tags_meta_boxes' );
The catch is that you have to select BOTH categories AND tags.
This is because of line 87 in \inc\post-type\register.php
$data = 1 == count( $value ) ? $value[0] : $value;
When you check only one of the check boxes either categories or tags, the count() of the array for taxonomies is 1 and $data becomes either 'category' or 'post_tag'. Then when the post type is registered on line 57, $args['taxonomies']
is not an array like it is expecting.
I've generated the following custom metaboxes using the online generator but I'm having trouble making this content "show up" under my desired CPT
/* Metabox Code */
function MatchlessProperty( $meta_boxes ) {
$prefix = 'MW';
$meta_boxes[] = array(
'id' => 'mwlistingdetails',
'title' => esc_html__( 'MW Listing Details', 'matchless-property' ),
'post_types' => array( 'post' ),
'context' => 'normal',
'priority' => 'default',
'autosave' => true,
'fields' => array(
array(
'id' => $prefix . 'tagline',
'type' => 'text',
'name' => esc_html__( 'Tagline', 'matchless-property' ),
'placeholder' => esc_html__( 'i.e. Awesome Hunting Land', 'matchless-property' ),
),
array(
'id' => $prefix . 'address',
'type' => 'text',
'name' => esc_html__( 'Address', 'matchless-property' ),
'placeholder' => esc_html__( 'i.e. 101 County Rd.', 'matchless-property' ),
),
array(
'id' => $prefix . 'county',
'name' => esc_html__( 'County', 'matchless-property' ),
'type' => 'select',
'placeholder' => esc_html__( 'Select an Item', 'matchless-property' ),
'options' => array(
'Adams' => 'Adams',
'Alcorn' => 'Alcorn',
'Amite' => 'Amite',
'Attala' => 'Attala',
'Benton' => 'Benton',
'Bolivar' => 'Bolivar',
'Calhoun' => 'Calhoun',
'Chickasaw' => 'Chickasaw',
'Chocktaw' => 'Chocktaw',
'Claiborne' => 'Claiborne',
'Clarke' => 'Clarke',
'Clay' => 'Clay',
'Coahoma' => 'Coahoma',
'Copiah' => 'Copiah',
'Covington' => 'Covington',
'DeSoto' => 'DeC',
'Forrest' => 'Forrest',
'Franklin' => 'Franklin',
'George' => 'George',
'Greene' => 'Greene',
'Grenada' => 'Grenada',
'Hancock' => 'Hancock',
'Harrison' => 'Harrison',
'Hinds' => 'Hinds',
'Holmes' => 'Holn',
'Humphreys' => 'Humphreys',
'Issaquena' => 'Issaquena',
'Itawamba' => 'Itawan',
'Jackson' => 'j',
'Jasper' => 'Jac',
'Jefferson' => 'Jefferson',
'Jefferson Davis' => 'Jefferson',
'Jones' => 'Jones',
'Kemper' => 'Kemper',
'Lafayette' => 'Lafayette',
'Lamar' => 'Lamar',
'Lauderdale' => 'Lauderdale',
'Lawrence' => 'Lawrence',
'Leake' => 'Leake',
'Leflore' => 'Leflore',
'Lincoln' => 'Lincoln',
'Lowndes' => 'Lowndes',
'Madison' => 'Madison',
'Marion' => 'Marion',
'Marshall' => 'Marshall',
'Monroe' => 'Monroe',
'Montgomery' => 'Montgomeru',
'Neshoba' => 'Neshoba',
'Newton' => 'Newton',
'Oktibbeha' => 'Oktibbeha',
'Panola' => 'Panola',
'Pearl River' => 'Pearl',
'Perry' => 'Perry',
'Pike' => 'Pike',
'Pontotoc' => 'Pontotoc',
'Prentiss' => 'Prentiss',
'Quitman' => 'Quitman',
'Rankin' => 'Rankin',
'Scott' => 'Scott',
'Sharkey' => 'Sharkey',
'Simpson' => 'Simpson',
'Smith' => 'Smith',
'Stone' => 'Stone',
'Sunflower' => 'Sunflower',
'Tallahatchie' => 'Tasll',
'Tate' => 'Tate',
'Tippah' => 'Tippah',
'Tishomingo' => 'Tishi',
'Tunica' => 'Tunica',
'Union' => 'Tn',
'Walthall' => 'Walthall',
'Warren' => 'Warren',
'Washington' => 'Washington',
'Wayne' => 'Wayne',
'Webster' => 'Webster',
'Wilkinson' => 'Wilkinson',
'Winston' => 'Winston',
'Yalobusha' => 'Yalobusha',
'Yazoo' => 'Yazoo',
),
'std' => 'Adams',
),
array(
'id' => $prefix . 'price',
'type' => 'text',
'name' => esc_html__( 'Price', 'matchless-property' ),
'placeholder' => esc_html__( 'i.e. $500,000', 'matchless-property' ),
),
array(
'id' => $prefix . 'agent_1',
'type' => 'text',
'name' => esc_html__( 'Agent 1', 'matchless-property' ),
'placeholder' => esc_html__( 'i.e. Cole DeLong', 'matchless-property' ),
),
array(
'id' => $prefix . 'agent_1_phone',
'type' => 'text',
'name' => esc_html__( 'Agent 1 Phone', 'matchless-property' ),
'placeholder' => esc_html__( 'i.e. (601) 555-555', 'matchless-property' ),
),
array(
'id' => $prefix . 'agent_1_photo',
'type' => 'file_input',
'name' => esc_html__( 'Agent 1 Photo', 'matchless-property' ),
),
array(
'id' => $prefix . 'agent_2',
'type' => 'text',
'name' => esc_html__( 'Agent 2', 'matchless-property' ),
'placeholder' => esc_html__( 'i.e. John Doe', 'matchless-property' ),
),
array(
'id' => $prefix . 'agent_2_phone',
'type' => 'text',
'name' => esc_html__( 'Agent 2 Phone', 'matchless-property' ),
'placeholder' => esc_html__( '(601) 555-5555', 'matchless-property' ),
),
array(
'id' => $prefix . 'agent_2_photo',
'type' => 'file_input',
'name' => esc_html__( 'Agent 2 Photo', 'matchless-property' ),
),
array(
'id' => $prefix . 'status',
'name' => esc_html__( 'Status', 'matchless-property' ),
'type' => 'select',
'placeholder' => esc_html__( 'Select an Item', 'matchless-property' ),
'options' => array(
'For Sale' => 'For Sale',
'Pending' => 'Pending',
'Leased' => 'Leased',
'For Lease' => 'For Lease',
),
'std' => 'For Sale',
),
array(
'id' => $prefix . 'google_map_upload',
'type' => 'file_advanced',
'name' => esc_html__( 'Google Map Upload', 'matchless-property' ),
'max_file_uploads' => 1,
'max_status' => true,
),
array(
'id' => $prefix . 'topo_map_upload',
'type' => 'file_advanced',
'name' => esc_html__( 'Topo Map Upload', 'matchless-property' ),
'max_file_uploads' => 1,
'max_status' => true,
),
array(
'id' => $prefix . 'aerial_map_upload',
'type' => 'file_advanced',
'name' => esc_html__( 'Aerial Map Upload', 'matchless-property' ),
'max_file_uploads' => 1,
'max_status' => true,
),
),
);
return $meta_boxes;
}
add_filter( 'rwmb_meta_boxes', 'MatchlessProperty' );
And now I'm trying to have these metaboxes "show up" in my custom post type created using the free Meta Box Custom Post Type plugin.
But I can't seem to make it happen. The metaboxes currently just appear under the standard wordpress posts. It may have to do with an incorrect setup of the custom post type. For reference here's the code for the CPT:
/*CPT Code - Which I'm guessing contains the error(s) */
function mwproperty_register_post_type() {
$args = array (
'label' => esc_html__( 'MW Properties', 'mwproperty' ),
'labels' => array(
'menu_name' => esc_html__( 'MW Properties', 'mwproperty' ),
'name_admin_bar' => esc_html__( 'MW Property', 'mwproperty' ),
'add_new' => esc_html__( 'Add new', 'mwproperty' ),
'add_new_item' => esc_html__( 'Add new MW Property', 'mwproperty' ),
'new_item' => esc_html__( 'New MW Property', 'mwproperty' ),
'edit_item' => esc_html__( 'Edit MW Property', 'mwproperty' ),
'view_item' => esc_html__( 'View MW Property', 'mwproperty' ),
'update_item' => esc_html__( 'Update MW Property', 'mwproperty' ),
'all_items' => esc_html__( 'All MW Properties', 'mwproperty' ),
'search_items' => esc_html__( 'Search MW Properties', 'mwproperty' ),
'parent_item_colon' => esc_html__( 'Parent MW Property', 'mwproperty' ),
'not_found' => esc_html__( 'No MW Properties found', 'mwproperty' ),
'not_found_in_trash' => esc_html__( 'No MW Properties found in Trash', 'mwproperty' ),
'name' => esc_html__( 'MW Properties', 'mwproperty' ),
'singular_name' => esc_html__( 'MW Property', 'mwproperty' ),
),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_nav_menus' => true,
'capability_type' => 'post',
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'supports' => array(
'title',
'editor',
'thumbnail',
'custom-fields',
),
'rewrite' => true,
);
register_post_type( 'mw-property', $args );
}
add_action( 'init', 'mwproperty_register_post_type' );
Any care to save a newbie?
Hi there,
This recently cropped up in development โ I was getting this notice:
Notice: Undefined index: meta_box_cb in /Users/jeremy/www/sites/gtt/-www-/site-content/plugins/meta-box-aio/vendor/meta-box/mb-custom-post-type/inc/taxonomy/register.php on line 83
I saw this with the newest version of WordPress (5.2.3), Twentynineteen theme, no plugins active besides Metabox and Metabox All-In-One.
Replacing this on line 83:
if ( false !== $args['meta_box_cb'] ) {
with this:
if ( isset( $args['meta_box_cb'] ) && false !== $args['meta_box_cb'] ) {
... fixed my issue. Happy to submit a pull request if that's helpful.
Thanks,
Jeremy
The Code tab in the Meta Box Builder plugin was the reason that I decided to start using it. It's a great tool to get things going quickly, and I can export the code and add it to my theme when I'm done to prevent my clients from breaking anything.
I'd like to request the same feature in the mb-custom-post-type plugin. I imagine it would be implemented in a similar way.
I noticed "menu_position" isn't working because Wordpress demands it to be Integer so I changed code in line 84 of file: "/inc/post-type/register.php":
$data = is_numeric( $data ) ? ( 1 === intval( $data ) ? true : false ) : $data;
to:
$data = ( $key === 'args_menu_position' ? intval($data) : ( is_numeric( $data ) ? ( 1 === intval( $data ) ? true : false ) : $data ) );
I would appreciate if you could change the plugin code.
I created a custom post type named "Portfolio" with slug "portfolio-wp" and taxonomy named "Category" with slug "portfolio-category" on my local site. I exported the XML and then tried to import on a live server with fresh WordPress install. But, there it is showing invalid post type for both custom post type and taxonomy.
Can you let me know how to resolve this issue?
It works with create new CPT, but not when edit custom post type.
Right now we have only updated messages for mb-post-type
, we should have them all for registered post types.
Hi, thanks for developing this plugin.
I was wondering if was possible to expose the custom posts in the Wordpress json REST API and if so how? At the moment I'm using WP 4.7 along with Meta Box, MB Custom Post Type and MB Rest API but I can only see normal posts/pages.
Thanks in advance
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.