Forum Replies Created
-
AuthorPosts
-
catacalyMemberThat’s what’s happening, using the latest version.
catacalyMemberThat only displays the default option, not the suppliers also 🙁
catacalyMemberI’m groggy right now but this is what I have so far for meta-boxes/product.php, which I threw together from some code found on these forums mixed with my own inferred:
<?php /* Title: Supplier Post Type: product Context: side */ piklist('field', array( 'type' => 'post-relate' ,'field' => 'Supplier' ,'scope' => 'product_supplier' ,'field' => 'prod_supplier' )); /* $relate = get_posts(array( 'post_type' => 'product_supplier' // Set post type you are relating to. ,'posts_per_page' => -1 // ,'post_belongs' => $post->ID ,'post_status' => 'publish' ,'suppress_filters' => false // This must be set to false )); foreach ($relate as $related): echo $related->post_title; endforeach; */ //$scope = "'product_supplier'"; $posts = get_posts(array( 'post_type' => $scope, 'post_belongs' => $post->ID, 'post_per_page' => -1, 'suppress_filters'=> false )); $default = get_post_meta( $post->ID, $field, true ); $default = empty($default) ? null : $default; piklist('field', array( 'type' => 'select', 'scope' => 'relate', 'field' => $scope . '_select_post_id', 'template' => 'field', 'value' => $default, 'choices' => piklist( get_posts(array( 'post_type' => 'product_supplier',//$scope, 'numberposts' => -1, 'orderby' => 'title', 'order' => 'ASC' )), array('ID', 'post_title') ), 'attributes' => array( 'class' => $scope . '_select_post_id' ) )); piklist('field', array( 'type' => 'hidden', 'field' => $field, 'value' => $default, 'attributes' => array( 'class' => $field . '_select_id' ) )); piklist('field', array( 'type' => 'hidden', 'scope' => 'relate', 'field' => $scope . '_select_relate', 'value' => 'has' )); piklist('field', array( 'type' => 'hidden', 'scope' => 'relate', 'field' => $scope . '_select_relate_remove', 'attributes' => array( 'class' => $scope . '_select_relate_remove' ) )); wp_reset_postdata(); ?> <script type="text/javascript"> (function($) { $(document).ready(function() { var $select = $('.<?php echo $scope . '_select_post_id'; ?>'), initialValue = <?php echo ( $default) ? $default : -1 ; ?>; $select.change(function(event) { event.stopPropagation(); var $remove = $('.<?php echo $scope . '_select_relate_remove'; ?>'), $hiddenID = $('.<?php echo $field . '_select_id'; ?>'), currentValue = $(this).val(), ids = []; if ( currentValue != initialValue ) { $(this).children('option').each(function() { var value = $(this).val(); if (value !== currentValue) ids.push($(this).val()); }); } $hiddenID.val(currentValue); $remove.val(ids.join(',')); }); }); })(jQuery); </script>
catacalyMemberI changed the value for post_type < get_posts < choices < field, still yields blank. What else do I need to change? Also how do I add a null default option?
catacalyMemberHow can I change this to a custom post type as the scope instead? I tried setting $scope = “‘my_cpt'”; didn’t work, options go blank.
catacalyMemberThe master field has got to switch what it updates the conditional field with depending on its own value… which has to be a variable self referenced?
catacalyMemberIs there a way to pass the child terms to update the reliant model field with choices? instead of just a value?
catacalyMemberOk it’s only with the Show ALL options option checked… I like that option too…
catacalyMemberThe latter error appears twice after the first one below the admin bar and then once in each of these top-level admin menu list item elements: Dashboard, Comments, Profile, and Tools…
July 19, 2014 at 12:29 pm in reply to: Taxonomies with 'hide_meta_box' => true still showing metaboxes? #2032
catacalyMemberIs there an easy-peasy-Piklist way of adding custom or default fields to admin columns?
July 19, 2014 at 12:12 pm in reply to: Taxonomies with 'hide_meta_box' => true still showing metaboxes? #2031
catacalyMemberThanks. I should’ve tried that.
Same with show_admin_column, while you’re at it 🙂
July 18, 2014 at 11:41 am in reply to: Taxonomies with 'hide_meta_box' => true still showing metaboxes? #2028
catacalyMemberadd_filter('piklist_post_types', 'listing_post_type'); function listing_post_type($post_types) { $post_types['vessel'] = array( 'labels' => piklist('post_type_labels', 'Listing') ,'title' => __('Enter boat name') ,'public' => true ,'hierarchical' => false ,'has_archive' => true ,'rewrite' => false/*array( 'slug' => 'vessel' )*/ ,'supports' => array( 'title' ,'author' ,'revisions' ,'thumbnail' //,'editor' //,'excerpt' ) ,'can_export' => true ,'edit_columns' => array( 'title' => __('Name') ,'author' => __('Created by') ) ,'hide_meta_box' => array( 'slug' ,'author' //,'revisions' //,'comments' //,'commentstatus' ) ,'post_states' => true ,'status' => array( 'draft' => array( 'label' => 'Draft' ,'public' => false ) ,'active' => array( 'label' => 'For Sale' ,'public' => true ) ,'inactive' => array( 'label' => 'Inactive' ,'public' => false ) ,'contract' => array( 'label' => 'Under Contract' ,'public' => true ) ,'sold' => array( 'label' => 'Sold' ,'public' => true ) ,'expired' => array( 'label' => 'Expired' ,'public' => false ) ) ,'capabilities' => array( 'edit_post' => 'edit_listing', 'edit_posts' => 'edit_listings', 'edit_others_posts' => 'edit_others_listings', 'publish_posts' => 'publish_listings', 'read_post' => 'read_listing', 'read_private_posts' => 'read_private_listings', 'delete_post' => 'delete_listing' ) ,'map_meta_cap' => true ); return $post_types; } function apply_listing_caps() { // gets the administrator role $admins = get_role( 'administrator' ); $admins->add_cap( 'edit_listing' ); $admins->add_cap( 'edit_listings' ); $admins->add_cap( 'edit_others_listings' ); $admins->add_cap( 'publish_listings' ); $admins->add_cap( 'read_listing' ); $admins->add_cap( 'read_private_listings' ); $admins->add_cap( 'delete_listing' ); add_role( 'dd', 'DD', array( 'edit_listing' => true, 'edit_listings' => true, 'edit_others_listings' => true, 'publish_listings' => true, 'read_listing' => true, 'read_private_listings' => true, 'delete_listing' => false )); } add_action( 'admin_init', 'apply_listing_caps'); add_filter('piklist_taxonomies', 'vessel_make_models'); function vessel_make_models($taxonomies) { $taxonomies[] = array( 'post_type' => 'vessel' ,'name' => 'make' ,'show_admin_column' => true ,'hide_meta_box' => true ,'configuration' => array( 'hierarchical' => false ,'labels' => piklist('taxonomy_labels', 'Manufacturer') ,'show_ui' => true ,'query_var' => true ,'rewrite' => array( 'slug' => 'make' ) ) ); $taxonomies[] = array( 'post_type' => 'vessel' ,'name' => 'model' ,'show_admin_column' => true ,'hide_meta_box' => true ,'configuration' => array( 'hierarchical' => false ,'labels' => piklist('taxonomy_labels', 'Model') ,'show_ui' => true ,'query_var' => true ,'rewrite' => array( 'slug' => 'model' ) ) ); return $taxonomies; }July 17, 2014 at 4:58 pm in reply to: Best way to set up make/model settings for custom listing post type? #2023
catacalyMemberAlong the lines of what I had in mind…
Although, this site is supposed to have hundreds-thousands of listings that each hold a good amount of data. In addition to make/model there are some other fields that should be searchable/filterable/browseable, not unlike taxonomies; but make/model will have more options than the others which is why I’m focusing on them.
But in terms of performance, should I perhaps avoid using taxonomies altogether, to keep the metadata consistent in form, too? Maybe instead of taxonomies the makes/models can just be managed from the CPT’s settings? What would you (anyone) suggest as a more optimal approach?
-
AuthorPosts