Custom meta box includes

Debugging in WordPress The following could/should be set in the wp-config.php file of your local(!!) installation – never do this on a live site, especially not when you got caching activated! define( ‘WP_CACHE’, false ); // Show the development files for scripts/stylesheets and don’t combine them define( ‘COMPRESS_CSS’, false ); define( ‘SCRIPT_DEBUG’, true ); define( … Read more

Metaboxes not saving data

There were three issues: The first wasn’t visible in the code presented. a wp_register_styles call was put into the constructor, which caused errors and somehow prevented saving post metadata. Second, the date field was a HTML5 date field, which conflisted with jQuery’s datepicker. Changing it to a text field fixed that. Third, the final if … Read more

Custom metabox with App Store / Google Play links

Ok, with the use of this ‘plugin’ (JareDatch). It works like a charm. add_filter( ‘cmb_meta_boxes’, ‘cmb_sample_metaboxes’ ); /** * Define the metabox and field configurations. ** @param array $meta_boxes * @return array */ function cmb_sample_metaboxes( array $meta_boxes ) { // Start with an underscore to hide fields from custom fields list $prefix = ‘_cmb_’; $meta_boxes[] … Read more

How to query custom post then display sections by meta value

I would recommend executing two separate queries, each one differing from the other via a meta_query against your post custom meta key value. $current_query_args = array( ‘post_type’ => ‘recipient’, ‘meta_query’ => array( array( ‘key’ => ‘yes_current’, ‘value’ => ‘on’, ‘compare’ => ‘=’ ) ) ); $current_query = new WP_Query( $current_query_args ); if ( $current_query->have_posts() ) … Read more

Remove duplicated values from meta box values

Solution I created array outside the while loop and checked if the value is in array or not. <?php $args = array(‘post_type’ => ‘posttype’); $emptyvalue = “”; $optionname = “optionname”; $the_query = new WP_Query($args); $output =”<select name=””.$optionname.””> <option value=””.$emptyvalue.””>Location</option>'”; $arr = array(); while ( $the_query->have_posts() ) : $the_query->next_post(); $id= $the_query->post->ID; $location = get_post_meta($id, ‘institution_location’, true); … Read more

why esc_url not working in smartmetabox

esc_url() is not a validator. Use PHP’s filter functions for that. Example: // $url is now an URL or FALSE $url = filter_var( ‘http://example.com’, FILTER_VALIDATE_URL ); if ( $url ) # update post meta else # delete post meta

Meta Boxes causing Header errors

It is probably here: if ( !wp_verify_nonce( $_POST[‘address_noncename’], plugin_basename(__FILE__) )) { return $post->ID; } You are using $_POST[‘address_noncename’] but aren’t checking to see if it exists before you do. That is going to trigger the warning you mentioned about an “undefined index”. If that warning prints to the screen before the headers are sent, you … Read more

loop through custom post-type with two meta_keys

You’ll need to use meta_query along with meta_(key|value|compare) to interact with two different keys and get the order you want. <?php $q = new WP_Query(array( ‘post_type’ => ‘my_project’, ‘nopaging’ => true, // same as posts_per_page => 1, ‘order’ => $order, ‘orderby’ => ‘is_featured_position’, // your position key here ‘meta_key’ => ‘is_featured_position’, // also here, see … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)