I was under the impression that if you add an underscore to your meta_key, it would be hidden from the Admin and subsequently the Order Receipts, etc.
But, mine are showing? I don't understand what's going on...
meta_key: _testing_this, meta_value: asdasdasd
How do I added order item meta without it showing up?
If I am understanding correctly, to hide order metadata, you could use the existing hook Hidden Order Item Meta.
You could possibly add this to your functions.php or wherever you are storing your customizations:
add_filter( 'woocommerce_hidden_order_itemmeta', 'add_your_hidden_order_items' );
function add_your_hidden_order_items( $order_items ) {
$order_items[] = '_testing_this';
// any other entries you want to hide..
return $order_items;
}
I'm not sure this will remove the meta from the admin view. It may be worth while looking at this post about customizing the order meta box.
I hope this helps.
The answer is to serialize the data you want to be hidden.
Related
When I use vc_map() to add a new element to the content element list there is the category parameter to put the element in a certain tab.
If there are to many category tabs, VC will put some of them in a dropdown list on the right hand side. Is there a way to rearrange the order of all tabs?
There's a filter that can be hooked into to rearrange the order of the element categories: vc_add_element_categories.
For example:
add_filter( 'vc_add_element_categories', 'rearrange_element_categories', 10, 1 );
function rearrange_element_categories( $tabs ) {
// rearrange the tabs according to your needs
return $rearranged_tabs;
}
Don't know why someone would need this? Still you can arrange this as per your choice by jumping into plugin's code.
Con:
It will get reset, when in future you will be updating the plugin. And as per our understanding for WPBakery Page Builder plugin, you can't survive by without updating it.
Hi and thanks in advance for any help,
I need to debug the woocommerce checkout page in which some fields of the form billing are not aligned correctly for some countries.
i saw that the issue is resolved if i add a after the postcode field, the function woocommerce_form_field( $key, $args, $value = null ) adds that div if $args['clear'] is not empty and it's called in a foreach for the checkout page in the checkout/form-billing.php file.
woocommerce_form_field(...) is in woocommerce/includes/wc-template-functions.php.
The $args contains the clear attribute correctly and woocommerce_form_field returns the field with div correctly (mailed myself the data from the function), when i get to the page the div is not there and fields are not aligned. Also i noticed that if i try to echo something it doesn't appear on the page source but if i mail the data from the same form-billing.php spot the data is received correctly.
How can i make the div show correctly ? What javascript could rewrite the form and where can i edit it ?
the fields disaligns if you select United States in the country select.
Any suggestion would be appreciated
P.S.: i added some javascript that adds the div on document.onload but it feels dirty and i'm not sure it works in every case.
EDIT: rephrase, clarify
To be safe when updating woocommerce in future versions you should do the following:
Best is to replace checkout.min.js with your own modified version.
Placing this in your functions.php should load your modified script
$wp_scripts->registered[ 'wc-checkout' ]->src = get_stylesheet_directory_uri() . '/js/yourmodifiedcheckout.js';
Hope this helps, let me know if you need further help.
what I was trying to do here is to remove some custom fields that I created when a template is selected, aka when I select certain template I want to hide or show specific metaboxes.
The code I have is the following but it isn't working at all (thats to say that it doesn't remove any metaboxes) and I would like help to see what's wrong with it or if what I'm trying to do it's just not posible.
add_action('admin_init','my_meta_init');
function my_meta_init(){
$template_file = get_post_meta(get_the_ID(), '_wp_page_template', TRUE);
if (($template_file == 'thanks-template.php') || ($template_file == 'view-template.php'))
{
remove_meta_box('my_meta_box_id','page','normal');
remove_meta_box('my_meta_box_id_2','page','side');
remove_meta_box('my_meta_box_id_3','page','side');
remove_meta_box('dynamic_sectionid','page','normal');
} else
{
remove_meta_box('my_meta_box_id_4','page','normal');
}
}
Thanks you for the comments and answer, everyone helped. The problem was on the hook I was using, I changed it and now it's working perfectly :
add_action('admin_head','my_meta_init');
You may need to change the HOOK you are using to hook in your function.
That is you need to hook into admin_menu instead of admin_init as the metaboxes might not exist the moment you are trying to remove them. So a certain order is needed to make sure metaboxes removal call is made when actual metaboxes are generated and exist.
I tested following code on my localhost and it hid the Author div/metabox fine when used this code snippet:
function remove_page_fields() {
remove_meta_box( 'authordiv' , 'page' , 'normal' ); //removes author
}
add_action( 'admin_menu' , 'remove_page_fields' );
Another Approach:
By the way, as I think about the situation you are facing, maybe add the metaboxes/custom fields in such a way, that they are shown only to the pages we are meant to. I have worked on projects where I need to show some metaboxes only when certain template is selected.
I use CMB2 class to generate metaboxes mostly, if you happen to use that or something similar, you may use this parameter to specify the page templates https://github.com/WebDevStudios/CMB2/wiki/Display-Options#limit-to-specific-page-templates
I am trying to display the comments of a post in a custom page in wordpress. I want to display all the comments including sub-comments. There is any way to display the comments of corresponding post?the_comments() shows all the comments in the database. Can I use get_the_commets($args)?
get_comments() would do the trick for you.
$comments = get_comments(array('post_id'=>YOUR_ID));
will return you an array of comments for particular post.
You can check get_comments page for more options
I have more than 2000 posts and each post contains almost 1000+ tags. Now i want to update all the posts with new additional tags in one go. Is there any simple way??
Regards-
From the dashboard:
Go to Posts -> All Posts
Beside Title there is a checkbox, check it and it will check all the boxes down the page.
Above the checkbox there is a dropdown list, select Edit and press Apply
You will see an input box called Tags, add the new tag in there
Next click the update button and those posts will now have the new tag.
I would recommend that you do this for one or two posts first to make sure it will work as you want and not break/mess anything up.
You have one more option, if some of the tags are similar for all the posts. You can post a piece of code in your function.php file and put the list of common tags there :
function my_tag_update () {
GLOBAL $post;
wp_set_post_tags( $post->ID, 'tag1, tag2, tag3, tag4', true );
}
add_action('publish_post', 'my_tag_update');
add_action('save_post', 'my_tag_update');
So, in this case when you create a new post or edit a post, these defined tags will add to it automatically.