New answers tagged

0

Since you are using this code in the shortcode, I suppose the reason is the lack of post ID. You want to get the ID of the current post from the $post variable, but to make it possible you need to add the global $post; earlier (at the beginning of the function, or at least before the IF). global $post; if ( isset( $_POST['zon_testimonial_nonce'] ) &&...


0

Where do you put this script? The form will be submitted to index.php if you don't specify Form Action : <form method="post" action="yourfile.php">


1

The is_page() conditional relies on the global $wp_query WP_Query object which isn't set on the edit post page. We have some other options though... If we know the page ID we can test against $_GET: /** * Remove metaboxes * * @return void */ function wpse343020_remove_meta_boxes() { if( isset( $_GET, $_GET['post'] ) && 123 == $_GET['post']...


0

That is easy, you are trying to update the wrong value. Please replace the following if ( isset($_POST['package']) ) update_post_meta($post_id, 'zon_package', esc_sql($_POST['zon_package']) ); if ( isset($_POST['zon_phone']) ) update_post_meta($post_id, 'phone', esc_sql($_POST['phone']) ); With this: $zon_package = ''; $zon_phone = ''; if ( isset($...


1

I know this question has been asked for a while but below is my own contribution; add_action( 'add_meta_boxes', function () { add_meta_box( 'yourcustom_sectionid', __( '👋 Custom Meta Box', 'yourtextdomain' ), 'enter_your_callback_function_here', 'posttype_id', 'side', 'default' ); } ); function ...


0

After some experimentation, I have come up with this method which may be a tad more robust: add_action('add_meta_boxes', function () { $screens = array('post', 'page'); foreach ($screens as $screen) { add_meta_box("metabox_name", "Meta Box Title", "my_metabox_callback", $screen, "side", "high"); // Force the box to display below ...


0

I am working on a plugin that will be using custom fields, but was curious if there was a way to tell which plugin/library created those custom fields. WP doesn't store any meta information in the database about post meta and what plugins touched it. WP doesn't sandbox plugins at all, so once they're loaded it's all considered code. As such WP core code is ...


0

There is an error in setting variable on this line: $week_s1="_member_score_".$week._s1"; this line should be $week_s1 ="_member_score_".$week."_s1";


1

To hide meta_box from Block Editor and display them only in classic editor add arg __back_compat_meta_box set to true when adding meta box add_meta_box( 'my-meta-box', 'My Meta Box', 'my_meta_box_callback', null, 'normal', 'high', array( '__back_compat_meta_box' => true, ) );


0

I had one more look at the code and I realized the save function was missing couple of checks. So replace meta_boxes.php:366 with this, if ( empty( $_POST['nonce_car_details'] ) ) { return; } check_admin_referer( 'save_car_details_meta', 'nonce_car_details' ); if ( ! current_user_can( 'edit_post', $post_id ) ) { return; } if ( wp_is_post_autosave( $...


0

Update 29.6.19 I think the array_map() error is actually caused by how the selects are named. They have names like tax_input[fuel-type], which probably results in them getting passed to the default taxonomy saving function. As only single value is passed for each select and I assume the tax save handler expects an array, the array_map() warning is raised. ...


Top 50 recent answers are included