- This topic has 5 replies, 3 voices, and was last updated 6 years ago by
Steve.
-
AuthorPosts
-
-
January 8, 2016 at 1:40 am #5522
shayneolMemberHello,
I know that if I wanted to show certain meta-boxes on a specific page, I would type
ID:4(where ‘4’ is the page/post id) in the comment section of that meta-box file. However, this doesn’t seem to work for Workflow Tabs. I can hide all of the meta boxes in a tab, but the empty tab still shows and addingID:4to the actual tab doesn’t do anything. Is there a way to only display tabs (and their contents) for specific page/posts (i.e. if I were to have the Homepage and About page to have different workflow tabs and input boxes that only show on their respective pages)?Thanks for your time,
Shayne -
January 13, 2016 at 9:32 pm #5587
mcmasterMemberHi, this is the same question as was asked here:
And it was answered with a pointer to here:
And I believe the latter was left as something that will be fixed in the next release.
-
January 14, 2016 at 9:00 pm #5614
shayneolMemberThanks for your help. I noticed that on the “show fields conditioned on taxonomy term?” post that you mentioned (https://piklist.com/support/topic/show-fields-conditioned-on-taxonomy-term/) you didn’t say if you got it to work. I’ve been trying for quite a bit of time, but cannot seem to get it right. Even with the articles that you mentioned and this other one that was posted (https://piklist.com/support/topic/disable-a-metabox/), I haven’t had much luck. I’ve tried the following:
Workflow Header File
<?php /* Flow: Homepage Workflow Page: post.php, post-new.php, post-edit.php Post Type: page Header: true Position: title Clear: true ID: 5 */Workflow Tab File
<?php /* Title: Intro Order: 10 Flow: Homepage Workflow Default: true ID: 5 */Metabox File
<?php /* Title: Intro Section Post Type: page Order: 10 Lock: true Tab: Intro Flow: Homepage Workflow */ //Intro Text piklist('field', array( 'type' => 'group' ,'field' => 'home_intro_text' ,'label' => __('Intro Text', 'piklist-demo') ,'list' => false ,'description' => __('Please type the introduction text that will be placed at the top of the page.', 'piklist-demo') ,'fields' => array( array( 'type' => 'text' ,'field' => 'title' ,'label' => __('Title', 'piklist-demo') ,'columns' => 12 ) ,array( 'type' => 'editor' ,'field' => 'intro_text' ,'label' => __('Text', 'piklist-demo') ,'options' => array( 'wpautop' => true ,'media_buttons' => true ,'shortcode_buttons' => true ,'teeny' => false ,'dfw' => false ,'tinymce' => array( 'resize' => false ,'wp_autoresize_on' => true ) ,'quicktags' => true ,'drag_drop_upload' => true ) ,'on_post_status' => array( 'value' => 'lock' ) ) ) )); //Video piklist('field', array( 'type' => 'group' ,'field' => 'home_intro_video' ,'label' => __('Intro Text', 'piklist-demo') ,'list' => false ,'description' => __('Homepage Video', 'piklist-demo') ,'fields' => array( array( 'type' => 'select' ,'field' => 'video_type' ,'label' => __('Video Type', 'piklist-demo') ,'choices' => array( 'youtube' => __('Youtube', 'piklist-demo') ,'vimeo' => __('Vimeo', 'piklist-demo') ) ) ,array( 'type' => 'text' ,'field' => 'video_url' ,'label' => __('Video URL', 'piklist-demo') ,'columns' => 12 ,'attributes' => array( 'placeholder' => 'http://' ) ) ) ));I first started out simple by just trying to hide a metabox using filters before I jumped into removing tabs based on the post_id, but the following code (and multiple variations of it) wouldn’t work.
Functions.php
function my_disable_metabox($part_data, $folder) { if (isset($part_data['title']) && $part_data['title'] == 'Intro Section') { return; } return $part_data; } add_filter('piklist_part_add','my_disable_metabox', 10, 2);If you were able to get yours to work, am I missing something?
Thanks,
Shayne -
January 16, 2016 at 11:57 pm #5645
SteveKeymasterWhat version of Piklist are you using?
piklist_part_addchanged in v0.9.9.x. Usepiklist_part_process_callbackadd_filter('piklist_part_process_callback','my_disable_metabox', 10, 2); -
January 17, 2016 at 5:59 pm #5651
shayneolMember🙂 Thanks Steve. That was the final piece. I am using piklist v.0.9.9.7, so
piklist_part_process_callbackworked. Also, looking at$part_data, I had to change the conditional to match the correct entry of the array. For anyone that might need this, my final code is below. I have two different sets of workflow tabs, one to display only on my homepage (post_id: 5) and the other set to display only on my about page (post_id: 34).function my_disable_metabox($part_data, $folder) { // get post ID if ( isset( $_REQUEST['post'] ) ) { $post_id = $_REQUEST['post']; } elseif ( isset( $_REQUEST['post_ID'] ) ) { $post_id = $_REQUEST['post_ID']; } // Display the correct Workflow on the correct page if ( ($post_id != 5) && $part_data['data']['flow'][0] == 'homepage_workflow' ) { return; } else if ( ($post_id != 34) && $part_data['data']['flow'][0] == 'about_workflow' ) { return; } return $part_data; } add_filter('piklist_part_process_callback','my_disable_metabox', 10, 2);Thanks Again!
-
January 18, 2016 at 5:44 pm #5660
SteveKeymasterAwesome! Looks great. Closing ticket.
-
-
AuthorPosts
- The topic ‘Hide Workflow Tabs For Specific Page’ is closed to new replies.