Giter VIP home page Giter VIP logo

mb-custom-post-type's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mb-custom-post-type's Issues

Handle rewrite correctly

Is this able to handle rewriting correctly?

Working only for the first level: /post_type/child

Doesn't work: /post_type/child/grandchild

Access custom post type in WP REST API

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

Flush rewrite rules

Flush rewrite rules only when:

  1. Plugin is activated - to register mb-post-type (maybe not needed because the post type is used internally)
  2. When update custom post type

Unable to import custom post type and taxonomy

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?

Full code to register mb-post-type

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.

How do I make metaboxes "show up" under my desired CPT?

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?

Support rewrite options for taxonomies

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.

Menu position isn't working

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.

Categories and/or Tags Support for Custom Post Types

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.

Separate labels and settings

I think we should create 2 meta boxes for:

  1. Labels
  2. Advanced Settings

These meta boxes are hidden by default, and when click Advanced button, they will be shown.

Export PHP code

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.

Allow to set "Prepend Permalink Structure" for post type registration

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:

prepend-permalink-option.zip

Thanks.

Undefined index 'meta_box_cb' in taxonomy/register.php

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

hide main post type 'mb-post-type' option

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.

Critical error on update to version 2.3.0

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

Error Details

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.