Hide custom fields by user’s role

You can use the current_user_can() function to test the current user’s role. I would also recommend making the custom field protected by default and allowing access only to the proper users. In theory, something like this should work: function my_exclude_custom_fields( $protected, $meta_key) { if ( in_array( $meta_key, array( ’email’, ‘text’ ) ) ) { if … Read more

a lot of custom fields

Like Joel M asked, it really depends on what you mean by “a lot of posts”. It also depends a lot on if you’re querying these posts in complicated ways. I highly recommend you install the plugin Query Monitor (https://wordpress.org/plugins/query-monitor/). It will tell you how long various queries are taking. You can then create “a … Read more

Taxonomy question

The short answer is to get your taxonomy terms using: wp_get_post_terms( $post->ID, ‘yourTaxonomyName’ ); This will return an array of WP Term Objects. Here’s how you would get the first term name: $terms = wp_get_post_terms( $post->ID, ‘yourTaxonomyName’ ); $first_term_name = $terms[0]->name; You can learn more about this method in the WordPress Codex: https://codex.wordpress.org/Function_Reference/wp_get_post_terms Hope this … Read more

Simple Data picker meta box

No ones was answering so i installed this plugin MetaBox.io and I’ve generated this code below that worsk very vell. function arrivo_metabox( $meta_boxes ) { $prefix = ‘arrivo-‘; $meta_boxes[] = array( ‘id’ => ‘arrivo’, ‘title’ => esc_html__( ‘Data di arrivo in negozio’, ‘porto-child’ ), ‘post_types’ => array( ‘riparazioni’ ), ‘context’ => ‘side’, ‘priority’ => ‘default’, … Read more