Skip to main content
added 283 characters in body
Source Link
Jared
  • 3.8k
  • 3
  • 34
  • 58

Try changing:

<input class="widefat" type="text" placeholder="[galleryview id=X]" name="rs-job-gallery" id="rs-job-gallery" value="<?php echo esc_attr( get_post_meta( $object->ID, 'rs_job_gallery', true ) ); ?>" size="30"/>

to this:

<input class="widefat" type="text" placeholder="[galleryview id=X]" name="rs_job_gallery" id="rs-job-gallery" value="<?php echo esc_attr( get_post_meta( $object->ID, 'rs_job_gallery', true ) ); ?>" size="30"/>

Reason: When the "name" attribute is set in the input field, that becomes the $_POST['input_name'] variable. Your custom meta name needs to use underscores so your input field's name should as well.

If that's not the case, tryAlso you need to change this in your save_post hookcode:

$new_meta_value = ( isset( $_POST['rs_job_gallery'] ) ? sanitize_html_class( $_POST['rs_job_gallery'] ) : '' );

to see if that variable is even being setsomething like this:

die$new_meta_value = ( var_dumpisset( $_POST['rs_job_gallery'] ) ? esc_attr( $_POST['rs_job_gallery'] ) : '' );

Since sanitize_html_class strips it down to numbers and letters so it can be used as a class in an element, but that's not what you want.

Try changing:

<input class="widefat" type="text" placeholder="[galleryview id=X]" name="rs-job-gallery" id="rs-job-gallery" value="<?php echo esc_attr( get_post_meta( $object->ID, 'rs_job_gallery', true ) ); ?>" size="30"/>

to this:

<input class="widefat" type="text" placeholder="[galleryview id=X]" name="rs_job_gallery" id="rs-job-gallery" value="<?php echo esc_attr( get_post_meta( $object->ID, 'rs_job_gallery', true ) ); ?>" size="30"/>

Reason: When the "name" attribute is set in the input field, that becomes the $_POST['input_name'] variable. Your custom meta name needs to use underscores so your input field's name should as well.

If that's not the case, try this in your save_post hook to see if that variable is even being set:

die( var_dump( $_POST['rs_job_gallery'] ) );

Try changing:

<input class="widefat" type="text" placeholder="[galleryview id=X]" name="rs-job-gallery" id="rs-job-gallery" value="<?php echo esc_attr( get_post_meta( $object->ID, 'rs_job_gallery', true ) ); ?>" size="30"/>

to this:

<input class="widefat" type="text" placeholder="[galleryview id=X]" name="rs_job_gallery" id="rs-job-gallery" value="<?php echo esc_attr( get_post_meta( $object->ID, 'rs_job_gallery', true ) ); ?>" size="30"/>

Reason: When the "name" attribute is set in the input field, that becomes the $_POST['input_name'] variable. Your custom meta name needs to use underscores so your input field's name should as well.

Also you need to change this code:

$new_meta_value = ( isset( $_POST['rs_job_gallery'] ) ? sanitize_html_class( $_POST['rs_job_gallery'] ) : '' );

to something like this:

$new_meta_value = ( isset( $_POST['rs_job_gallery'] ) ? esc_attr( $_POST['rs_job_gallery'] ) : '' );

Since sanitize_html_class strips it down to numbers and letters so it can be used as a class in an element, but that's not what you want.

Source Link
Jared
  • 3.8k
  • 3
  • 34
  • 58

Try changing:

<input class="widefat" type="text" placeholder="[galleryview id=X]" name="rs-job-gallery" id="rs-job-gallery" value="<?php echo esc_attr( get_post_meta( $object->ID, 'rs_job_gallery', true ) ); ?>" size="30"/>

to this:

<input class="widefat" type="text" placeholder="[galleryview id=X]" name="rs_job_gallery" id="rs-job-gallery" value="<?php echo esc_attr( get_post_meta( $object->ID, 'rs_job_gallery', true ) ); ?>" size="30"/>

Reason: When the "name" attribute is set in the input field, that becomes the $_POST['input_name'] variable. Your custom meta name needs to use underscores so your input field's name should as well.

If that's not the case, try this in your save_post hook to see if that variable is even being set:

die( var_dump( $_POST['rs_job_gallery'] ) );