Forum Replies Created
-
AuthorPosts
-
guit4evaParticipantOk, that makes sense. Thanks so much 🙂
guit4evaParticipantIs it possible to do this though per single field? I need this to apply to one field, and not the whole metabox
guit4evaParticipantI’ve finally found the culprit, though I still don’t understand what is causing it:
I see that the Piklist fields show up twice in the Oxygen builder ‘dynamic data’ selector. But only for this particular custom post type. I don’t have duplicate metabox files, so I’m not sure why they are getting duplicated? The good news is that it’s working though, phew…
I’ll post back here with a solution for anyone else who might experience a similar problem with Piklist and Oxygen in future if I figure it out!
guit4evaParticipantJust a quick update:
The “Parent” dropdown in Page Attributes is showing up now – I had to add more pages to that custom post type (I misunderstood how it works – I thought you could add a parent from any custom post type).
I also made an error with this part:
'post_type' => 'establishment_type', it should just be'post_type' => 'establishment'. All is working correctly now. Thanks so much for the help, it’s all making a lot more sense now!
guit4evaParticipantHi Steve,
Thanks for your reply. I’ve set hierarchical to true, but only the menu order is showing (and not the parent dropdown). I’ve also followed the tutorial you linked, but am unable to get the custom post type pages to show up. This is what I have so far:
$post_types['establishment-option'] = array( 'labels' => piklist('post_type_labels', 'Establishment Options') , 'title' => __('Enter a new establishment option Title') , 'supports' => array( 'title' , 'editor' , 'post-formats' , 'page-attributes' , 'thumbnail', ) , 'public' => true , 'admin_body_class' => array( 'custom-body-class', ) , 'hierarchical' => true , 'has_archive' => true , 'rewrite' => array( 'slug' => 'establishment-option', ) , 'capability_type' => 'post' );and
piklist('field', array( 'type' => 'select' ,'field' => 'sidebar_left' ,'label' => 'Establishment' ,'value' => 'none' ,'choices' => array( '' => 'Select Establishment' ) + piklist(get_posts(array( 'post_type' => 'establishment_type' ,'hide_empty' => false )) ,array( 'ID' ,'post_title' ) ) ));Can you see where I might be going wrong?
guit4evaParticipantEDIT: Oh gees…there’s the problem:
'choices' => piklist_demo_get_states()in line 86. My bad! Thanks so much for the help:)
————————————————————
Leaving the following here in case anyone else makes the same mistake
————————————————————This is the error that comes up:
Fatal error: Uncaught Error: Call to undefined function piklist_demo_get_states() in /usr/www/users/beautinf/wp-content/plugins/symia-piklist/parts/meta-boxes/establishment-metabox.php:86 Stack trace: #0 /usr/www/users/beautinf/wp-content/plugins/piklist/includes/class-piklist.php(523): include() #1 /usr/www/users/beautinf/wp-content/plugins/piklist/includes/class-piklist-meta.php(319): Piklist::render('/usr/www/users/...', Array) #2 /usr/www/users/beautinf/wp-admin/includes/template.php(1389): Piklist_Meta::meta_box(Object(WP_Post), Array) #3 /usr/www/users/beautinf/wp-admin/edit-form-advanced.php(686): do_meta_boxes(Object(WP_Screen), 'normal', Object(WP_Post)) #4 /usr/www/users/beautinf/wp-admin/post.php(206): require('/usr/www/users/...') #5 {main} thrown in /usr/www/users/beautinf/wp-content/plugins/symia-piklist/parts/meta-boxes/establishment-metabox.php on line 86This is my /parts/meta-boxes/establishment-metabox.php file:
<?php /* Title: Establishment Metabox Post Type: establishment */ piklist('field', array( 'type' => 'select', 'field' => 'establishment_type', 'label' => 'Establishment Type', 'choices' => array( 'guesthouse' => 'Guesthouse', 'villa' => 'Villa', 'cottage' => 'Cottage', 'apartment' => 'Apartment', ), )); piklist('field', array( 'type' => 'select', 'field' => 'establishment_no_bedrooms', 'label' => 'Number of Bedrooms', 'choices' => array( '1_bedroom' => '1', '2_bedroom' => '2', '3_bedroom' => '3', '4_bedroom' => '4', '5_bedroom' => '5', '6_bedroom' => '6', '7_bedroom' => '7+', ), )); piklist('field', array( 'type' => 'textarea', 'field' => 'rates', 'label' => 'Rates', 'add_more' => true, 'attributes' => array( 'rows' => 10, 'cols' => 50, 'class' => 'large-text', ) )); piklist('field', array( 'type' => 'group' ,'field' => 'address_group' // removing this parameter saves all fields as separate meta ,'label' => __('Address (Grouped)', 'piklist-demo') ,'list' => false ,'description' => __('A grouped field with the field parameter set.', 'piklist-demo') ,'fields' => array( array( 'type' => 'text' ,'field' => 'address_1' ,'label' => __('Street Address', 'piklist-demo') ,'required' => true ,'columns' => 12 ,'attributes' => array( 'placeholder' => 'Street Address' ) ) ,array( 'type' => 'text' ,'field' => 'address_2' ,'label' => __('PO Box, Suite, etc.', 'piklist-demo') ,'columns' => 12 ,'attributes' => array( 'placeholder' => 'PO Box, Suite, etc.' ) ) ,array( 'type' => 'text' ,'field' => 'city' ,'label' => __('City', 'piklist-demo') ,'columns' => 5 ,'attributes' => array( 'placeholder' => 'City' ) ) ,array( 'type' => 'select' ,'field' => 'state' ,'label' => __('State', 'piklist-demo') ,'columns' => 4 ,'choices' => piklist_demo_get_states() ) ,array( 'type' => 'text' ,'field' => 'postal_code' ,'label' => __('Postal Code', 'piklist-demo') ,'columns' => 3 ,'attributes' => array( 'placeholder' => 'Postal Code' ) ) ) ));
guit4evaParticipantAh, ok! Yes, I see how that could be very useful – especially if combining with something like Chosen. Piklist is really such a good addition to WordPress, really keen to learn about everything it can do 🙂
Thanks once again for your absolute stellar support!!!
Have a fantastic week 🙂
guit4evaParticipantAh ok! 🙂 I see it’s showing up now in the sidebar – yesss!! What is the difference though with that, and then adding them as I did in the previous post (piklist(‘field’, array(‘type’ => ‘select’…)? I see if I add a duplicate taxonomy to the taxonomy field in the right sidebar, it doesn’t reflect in the taxonomy selection in the Piklist main section – although I’d think they’d be the same thing?…I’ll add a picture to explain what I mean:
Sorry if that’s a silly question, just trying to understand how this all fits together.
guit4evaParticipantHi there Steve,
Thanks so much for your assistance. I discovered that I still needed to add the following to my parts file:
piklist('field', array( 'type' => 'select' ,'scope' => 'taxonomy' ,'field' => 'category' ,'label' => 'Categories' ,'description' => 'Terms will appear when they are added to this taxonomy.' ,'choices' => array( '' => 'Choose Term' ) + piklist(get_terms(array( 'taxonomy' => 'package_type' ,'hide_empty' => false )) ,array( 'term_id' ,'name' ) ) ));I was expecting the taxonomy section to show up in the right sidebar, which was what threw me off. It’s all working correctly now though 🙂
Thanks so much again for your help, it’s greatly appreciated!!
guit4evaParticipantIt’s in /wp-content/plugins/custom-pklist/custom.php. This is the full file:
<?php /** * Plugin Name: Custom Piklist Functions * Description: Custom Piklist Functions * Author: SS * Version: 0.1 * Plugin Type: Piklist */ add_filter('piklist_post_types', 'piklist_custom_post_types'); function piklist_custom_post_types($post_types) { $post_types['event'] = array( 'labels' => piklist('post_type_labels', 'Events') , 'title' => __('Enter a new Event Title') // ,'menu_icon' => piklist('url', 'piklist') . '/parts/img/piklist-menu-icon.svg' // ,'page_icon' => piklist('url', 'piklist') . '/parts/img/piklist-page-icon-32.png' , 'supports' => array( 'title' , 'editor' , 'post-formats' , 'thumbnail', ) , 'public' => true , 'admin_body_class' => array( 'custom-body-class', ) , 'has_archive' => true , 'rewrite' => array( 'slug' => 'event', ) , 'capability_type' => 'post' // ,'edit_columns' => array( // 'title' => __('Demo') // ,'author' => __('Assigned to') // ) , 'hide_meta_box' => array( 'author', ), // ,'status' => array( // 'new' => array( // 'label' => 'New' // ,'public' => false // ) // ,'pending' => array( // 'label' => 'Pending Review' // ,'public' => false // ) // ,'demo' => array( // 'label' => 'Demo' // ,'public' => true // ,'exclude_from_search' => true // ,'show_in_admin_all_list' => true // ,'show_in_admin_status_list' => true // ) // ,'lock' => array( // 'label' => 'Lock' // ,'public' => true // ) // ) ); $post_types['package'] = array( 'labels' => piklist('post_type_labels', 'Packages') , 'title' => __('Enter a new Package Title') // ,'menu_icon' => piklist('url', 'piklist') . '/parts/img/piklist-menu-icon.svg' // ,'page_icon' => piklist('url', 'piklist') . '/parts/img/piklist-page-icon-32.png' , 'supports' => array( 'title' , 'editor' , 'post-formats' , 'thumbnail', ) , 'public' => true , 'admin_body_class' => array( 'custom-body-class', ) , 'has_archive' => true , 'rewrite' => array( 'slug' => 'package', ) , 'capability_type' => 'post' // ,'edit_columns' => array( // 'title' => __('Demo') // ,'author' => __('Assigned to') // ) , 'hide_meta_box' => array( 'author', ), // ,'status' => array( // 'new' => array( // 'label' => 'New' // ,'public' => false // ) // ,'pending' => array( // 'label' => 'Pending Review' // ,'public' => false // ) // ,'demo' => array( // 'label' => 'Demo' // ,'public' => true // ,'exclude_from_search' => true // ,'show_in_admin_all_list' => true // ,'show_in_admin_status_list' => true // ) // ,'lock' => array( // 'label' => 'Lock' // ,'public' => true // ) // ) ); return $post_types; } add_filter('piklist_taxonomies', 'package_type_tax'); function package_type_tax($taxonomies) { $taxonomies[] = array( 'post_type' => 'package' ,'name' => 'package_type' ,'show_admin_column' => true ,'configuration' => array( 'hierarchical' => false ,'labels' => piklist('taxonomy_labels', 'Package Type') ,'hide_meta_box' => true ,'show_ui' => true ,'query_var' => true ,'rewrite' => array( 'slug' => 'package-type' ) ) ); return $taxonomies; }
guit4evaParticipantDrats, no luck… I’ve tried
'post_type' => 'post', checked Screen Options, nothing is showing in my cpt or in the default posts screen. Really stumped on this one!
guit4evaParticipantI don’t know what’s greater: the speed at which you replied or my embarrassment for such a silly mistake ha ha…
Thanks for that, however the issue still persists after correction:
add_filter('piklist_taxonomies', 'package_type_tax'); function package_type_tax($taxonomies) {Not sure what else I’m doing wrong?
guit4evaParticipantAh, Gutenberg was the issue! Yes, solved! Thanks so much for your help, much appreciated indeed! 🙂
guit4evaParticipantHi there Steve,
Apologies for that, I posted the wrong code (while troubleshooting). The code I have is in fact ‘post’:
function my_custom_init() { remove_post_type_support('post', 'custom-fields'); } add_action('init', 'my_custom_init');Unfortunately it’s still not working though.
guit4evaParticipantAh, ok! Thanks so much 🙂
-
AuthorPosts