Custom meta boxes not saving

You are accessing the $_POST array in a wrong way. This is not possible: $_POST[‘imagefields[‘ . $i . ‘][image2]’] Correct way would be: $_POST[‘imagefields’][$i][‘image2’]; (You have the same mistake when accessing the $values array.) Also you are supposed to give the complete array to the update_post_meta() function instead of saving each value seperately: if(isset($_POST[‘imagefields’])) { … Read more

Add custom data (field) to sidebar widgets for later display

Crude code. I have never tried this but I can get you part of the way there. Add a field… add_action( ‘in_widget_form’, function ($instance) { echo ‘<input type=”text” value=”c00l” />’; return null; }, 1 ); And there is a hook that runs on settings update. add_filter( ‘widget_update_callback’, function($instance, $new_instance, $old_instance, $this) { var_dump($instance, $new_instance, $old_instance, … Read more

Display custom widget value in header.php

The Codex is your friend. There’s a the_widget() function for that. <?php the_widget( ‘MY_Widget’, $instance, $args ); ?> Refer to the Codex entry for values for $instance and $args. $instance = array( ‘title’ => ‘Some Title here’, ‘name’ => ‘Some Name here’, ‘show_info’ => true ); $args = array( ‘before_widget’ => ”, // Your value … Read more

Sort posts by custom field value

This did the trick. I had to use ‘_year” <?php $query = new WP_Query(array( ‘post_type’ => array(‘gtcd’,’user_listing’), ‘posts_per_page’ => ‘999’, ‘meta_key’ => ‘_year’, ‘orderby’ => ‘meta_value’, ‘order’ => ‘ASC’ ));