Forum Replies Created
-
AuthorPosts
-
tsquez
ParticipantSo if I am trying to HIDE the
Featured Image OptionsTAB, where would I add the code from https://docs.metabox.io/extensions/meta-box-conditional-logic/#featured-image in the following:https://ghostbin.com/paste/pss7p
I have tried adding it to
Featured Image Optionstab but it still shows.What am I doing wrong?
P.S. yes i updated the conditional extension.
tsquez
ParticipantOh wow, unexpected. Thank you sir. I will take a look at it later today and let you know what I think.
Again, thank you for the update.
tsquez
ParticipantAwesome sir thank you. I appreciate any help.
tsquez
ParticipantHi there,
This is what I thought, however this will not work for me. See, in my theme one checkbox is available for the user. It is called "Hide Post/Page Title".
So when they install the plugin, that is when more checkboxes become available (the ones above). I just wanted to see if I could put them in order. If I can't...oh well....lol.
But thanks for trying anyway. I really do appreciate it.
tsquez
ParticipantHi there,
Yes I thought the same thing. However I misspoke. When I stated
Someone on another site who had a tutorial on meta boxes explained what I needed to do precisely and it worked beautifully.
I should have said the way they explained it on this other site made the code that Truong Giang gave me understandable.
Truong Giang gave me the following:
$option = rwmb_meta( 'xxxxxx-featured-image-options' ); if ( ! $option || 'show_blow_title' == $option ) { // do action. }So after I read the article on the other site, I took what Truong wrote and redid it like this:
$featured_image_layout = get_post_meta(get_the_ID(),'totalpress_featured_image_layout_options',true);
Then I wrote the code to display what I needed it to like this:
<?php if ($featured_image_layout === 'show_above_title' ): ?> <?php do_action('totalpress_featured_image_single'); ?> <?php endif; ?>and it worked out beautimously...lol.
So yes you did help but I did not understand at first and only when I understood is when what you gave me helped.
Thanks again for everything.
tsquez
ParticipantHi there,
Thank you for the reply. Sorry but my question was not how to set the order of metaboxes but the order of fields within a metabox. This is what I am using:
function tp_primo_edit_meta_boxes( $meta_boxes ) { // Loop throught all meta boxes to find the ones we need to change foreach ( $meta_boxes as $tp_primo_mb => $meta_box ) { // find the metabox we want to modify if ( isset( $meta_box['id'] ) && 'totalpress-post-page-options' == $meta_box['id'] ) { // then add the fields we want/need to our tab $meta_boxes[$tp_primo_mb]['fields'][] = array( 'id' => 'totalpress_featured_image_layout_options', 'type' => 'radio', 'options' => array ( 'page_header_contained' => esc_html__('Page Header Contained','tp-primo'), 'page_header_contained_title_overlay' => esc_html__('Page Header Cont. w/Title','tp-primo'), 'page_header_contained_title_overlay_parallax' => esc_html__('Page Header Cont. w/Title - Parallax','tp-primo'), 'page_header_full_width' => esc_html__('Page Header Full WIdth','tp-primo'), 'page_header_full_width_title_overlay' => esc_html__('Page Header FW w/Title','tp-primo'), 'page_header_full_width_title_overlay_parallax' => esc_html__('Page Header FW w/Title - Parallax','tp-primo'), ), 'tab' => 'totalpress_featured_image_options', 'inline' => false, 'std' => array ( 'show_below_title', ), ); $meta_boxes[$tp_primo_mb]['fields'][] = array( 'id' => 'tp_primo_page_header_height', 'type' => 'text', 'name' => esc_html__('Page Header Height','tp-primo'), 'desc' => esc_html__('Use PX, %, REM, EM and VH based values.','tp-primo'), 'tab' => 'totalpress_featured_image_options', ); } // find the metabox we want to modify if ( isset( $meta_box['id'] ) && 'totalpress-post-page-options' == $meta_box['id'] ) { // then add the fields we want/need to our tab $meta_boxes[$tp_primo_mb]['fields'][] = array( 'id' => 'tp_primo_set_content_area_width', 'type' => 'checkbox', 'desc' => esc_html__('Set Content Area to 100% Width','tp-primo'), 'tab' => 'totalpress_page_builder_options', ); } // find the metabox we want to modify if ( isset( $meta_box['id'] ) && 'totalpress-post-page-options' == $meta_box['id'] ) { // then add the fields we want/need $meta_boxes[$tp_primo_mb]['fields'][] = array( 'id' => 'tp_primo_page_options_hide_top_sidebar', 'type' => 'checkbox', 'desc' => esc_html__('Hide Post/Page Top Sidebar','tp-primo'), 'tab' => 'totalpress_hide_post_page_elements', ); $meta_boxes[$tp_primo_mb]['fields'][] = array( 'id' => 'tp_primo_page_options_hide_header', 'type' => 'checkbox', 'desc' => esc_html__('Hide Post/Page Theme Header','tp-primo'), 'tab' => 'totalpress_hide_post_page_elements', ); $meta_boxes[$tp_primo_mb]['fields'][] = array( 'id' => 'tp_primo_page_options_hide_navigation', 'type' => 'checkbox', 'desc' => esc_html__('Hide Post/Page Main Navigation','tp-primo'), 'tab' => 'totalpress_hide_post_page_elements', ); $meta_boxes[$tp_primo_mb]['fields'][] = array( 'id' => 'tp_primo_page_options_hide_featured_image', 'type' => 'checkbox', 'desc' => esc_html__('Hide Post/Page Featured Image','tp-primo'), 'tab' => 'totalpress_hide_post_page_elements', ); $meta_boxes[$tp_primo_mb]['fields'][] = array( 'id' => 'tp_primo_page_options_hide_footer_widgets', 'type' => 'checkbox', 'desc' => esc_html__('Hide All Post/Page Footer Widgets','tp-primo'), 'tab' => 'totalpress_hide_post_page_elements', ); $meta_boxes[$tp_primo_mb]['fields'][] = array( 'id' => 'tp_primo_page_options_hide_footer', 'type' => 'checkbox', 'desc' => esc_html__('Hide Post/Page Theme Footer','tp-primo'), 'tab' => 'totalpress_hide_post_page_elements', ); } } return $meta_boxes; } add_filter('rwmb_meta_boxes','tp_primo_edit_meta_boxes', 20);I was referring to the last section of that code
totalpress-post-page-options- there is a total of 6 checkboxes being added to that one specific metabox.My question was how to set the order of those checkboxes without having to create a function for each one.
I hope that made sense.
tsquez
ParticipantI would like to say thank you very much for taking the time and energy to show me how to use a meta box with radio fields. I did however figure it out but it was not with your solution.
Someone on another site who had a tutorial on meta boxes explained what I needed to do precisely and it worked beautifully.
Thanks for all the effort Anh and Truong put in.
tsquez
ParticipantHi there,
Thanks for the suggestion, however I do not think that will work.
I am going to try and explain this one more time using a different meta box..
OK, so I have a metabox that I created and here it is:
function how_do_I_use_radio_buttons_meta_box( $meta_boxes ) { $prefix = 'how_to_use_'; $meta_boxes[] = array( 'id' => 'how-to-use-radio-buttons', 'title' => esc_html__('How To Use Radio Fields','text-domain'), 'post_types' => array('post','page'), 'context' => 'side', 'priority' => 'default', 'autosave' => true, 'fields' => array( array( 'id' => $prefix . 'radio_buttons', 'type' => 'radio', 'placeholder' => 'boogie', 'options' => array( 'button_one_selected' => 'Radio Button One', 'button_two_selected' => 'Radio Button Two', 'button_three_selected' => 'Radio Button Three', 'button_four_selected' => 'Radio Button Four', 'button_five_selected' => 'Radio Button Five', ), 'inline' => false, ), ), ); return $meta_boxes; } add_filter( 'rwmb_meta_boxes', 'how_do_I_use_radio_buttons_meta_box' );As you can see there are five (5) choices. I have five (5) questions regarding this metabox:
First question: When a user selects Radio Button One, how would I display "I Clicked on Radio Button One" somewhere in the theme?
Second question: When a user selects Radio Button Two, how would I display "I Clicked on Radio Button Two" somewhere in the theme?
Third question: When a user selects Radio Button Three, how would I display the words "I Clicked on Radio Button Three" somewhere in the theme?
Fourth question: When a user selects Radio Button Four, how would I display the words "I Clicked on Radio Button Four" somewhere in the theme?
Fifth question: When a user selects Radio Button Five, how would I display the words "I Clicked on Radio Button Five" somewhere in the theme?
So if you could answer those questions, then maybe I can understand how to use radio fields in meta boxes ๐
tsquez
ParticipantOK I just re-read what i posted and your code does work perfectly. I just realized that I asked the wrong question.
I should have asked how do I display the featured image above the header when someone selects "show_above_title" etc. Or how do I display ALL of the options if one is selected like this:
if 'show_below_title' show this
if 'show_above_title' show this
if 'page_header_contained' show this
if 'page_header_contained_title_overlay' show this
if 'page_header_contained_title_overlay_parallax' show this
if 'page_header_full_width' show this
if 'page_header_full_width_title_overlay' show this
if 'page_header_full_width_title_overlay_parallax' show thisIn other words how do I use/display the information when someone selects one of the options, This is what is confusing me. This is what I am looking for. I am just trying to understand.
Thank you.
tsquez
Participanteither way I try and use the code you provided above, nothing is happening? What am I doing wrong?
tsquez
ParticipantHI there,
Thanks for taking the time to try and help me out. It's greatly appreciated. Unfortunately it is not working. Itried this:
if ( ! function_exists('totalpress_build_content_page_entry_header')) : function totalpress_build_content_page_entry_header() { ?> <?php $option = rwmb_meta('tp-primo-featured-image-options'); if ( $option || 'show_above_title' == $option ) { do_action('totalpress_featured_image_single'); } ?> <header class="entry-header"> <?php if (get_post_meta($post->ID,'totalpress_page_options_hide_title',true)) { the_title('<h1 class="entry-title hide" itemprop="headline">','</h1>'); } else { the_title('<h1 class="entry-title" itemprop="headline">','</h1>'); } ?> </header><!-- .entry-header --> <?php $option = rwmb_meta('tp-primo-featured-image-options'); if ( ! $option || 'show_below_title' == $option ) { do_action('totalpress_featured_image_single'); } ?> <?php } add_action('totalpress_content_page_entry_header','totalpress_build_content_page_entry_header'); endif;You can see where I added the code you referenced above, but it is not working. ANy idea what I am doing wrong? I am not getting any errors or warnings, so I don't know what it could be.
Thanks again for the help. It's greatly appreciated.
tsquez
ParticipantJust wanted to let you know that the information you had me read was SPOT ON!!!
After playing around with it, I got it working exactly the way I needed it to. Thank you so much and I appreciate the help. Merry Christmas to you and yours as well and very Happy and Prosperous New Year!
Thanks again ๐
tsquez
ParticipantYes I saw it on GitHub,
Thank you. I will have a look this weekend, however I am really not sure I understand...lol. I am really new to all of this metabox stuff but I find it very interesting.
I especially like everything your plugin offers and I plan on putting it to good use ๐
Thanks again. I may have some additional questions..lol
-
AuthorPosts