How can I change the publish date based on a custom field?

I don’t know how your front end form saves its data, but presumably it is using wp_insert_post and wp_update_post. If so, there is a filter called wp_insert_post_data that can be used to alter the post data before the post is inserted or updated. function reset_post_date_wpse_100021($data,$postarr) { var_dump($data,$postarr); die; //debug // your code return $data; } … Read more

How to calculate custom field value (average)

You can try this to fetch the custom values: $c1 = get_post_meta( get_the_ID(), ‘custom1’, TRUE ); $c2 = get_post_meta( get_the_ID(), ‘custom2’, TRUE ); $c3 = get_post_meta( get_the_ID(), ‘custom3’, TRUE ); $c4 = get_post_meta( get_the_ID(), ‘custom4’, TRUE ); Then to calculate the average: // check if c1, c2, c3 and c4 are all set: if( strlen($c1) … Read more

Meta value Array

If I understand you correctly, I don’t think this is a WordPress issue, just PHP. When you var_export into the textarea, then submit that via POST, what you then have is not an array but a string. You can check is_string instead of is_array to confirm this. If you want it to be an array … Read more

Save Custom Fields

I solved the problem with this code by creating again de meta box: // Add the Meta Box function add_custom_meta_box() { add_meta_box( ‘custom_meta_box’, // $id ‘Product Requirements’, // $title ‘show_custom_meta_box’, // $callback ‘produktkrav’, // $page ‘normal’, // $context ‘high’); // $priority } add_action(‘add_meta_boxes’, ‘add_custom_meta_box’); // Field Array $prefix = ‘custom_’; $custom_meta_fields = array( array( ‘label’=> … Read more

Automatically add a character to field in edit post page

Here is one idea: You could try to fire the change event of the #location-address (for example) input text field when the page has loaded: function custom_jquery() { echo “<script>jQuery(document).ready(function(){ jQuery(‘#location-address’).on( ‘change’, function( event ) { console.log(‘debug: on change fired!’); }); jQuery(‘#location-address’).change(); });</script>”; } add_action( ‘admin_head-post.php’, ‘custom_jquery’ ); if your editing page is post.php. You … Read more