Import data from arbitrary CSV to WPAlchemy meta fields

Here’s a piece of code similar to what I have used to fix the problem once imported the data: <?php define(‘MY_METABOX_ID’, ‘my_metabox_id’); define(‘MY_METABOX_PREFIX’, ‘my_metabox_prefix_’); define(‘MY_CUSTOM_POST_TYPE’, ‘my_custom_post_type’); // Include WordPress define(‘WP_USE_THEMES’, false); define(‘WP_DEBUG’, 1); require_once(‘../wp-load.php’); // extract all MY_CUSTOM_POST_TYPE posts $q = new WP_Query(‘post_type=” . MY_CUSTOM_POST_TYPE . “&nopaging=true’); // for each post while($q->have_posts()) { $q->next_post(); $p … Read more

Form fields based on custom fields

Our solution to this was to use Formidable Pro and the following setup. //************************************************** // Generate the contest form //************************************************** // Determin if radio or not add_filter(‘frm_field_type’, ‘change_my_field_type’, 10, 2); function change_my_field_type($type, $field){ global $post; if($field->id == 8){ if (get_post_meta($post->ID, ‘_cmeta_contest_q1_type’, true) !== ‘field’) { $type=”radio”; //change field to radio on multi-answer questions } else … Read more

How to add a prefix to existing custom fields over MYSQL query?

important: backup your database first! Assuming your table prefix is ‘wp_’, this query will change the custom field names: update wp_postmeta set meta_key = ‘booking_testfield’ where meta_key = ‘testfield’; NB: this also assumes that the custom field name is unique to your application, i.e. it isn’t used by another post type. If it is possible … Read more

Metabox nonce not allowing update

The issue was that you should have changed product_noncename to goal_info_meta_box_nonce. I’ve also made a few other changes, commenting out the old lines for comparison, which should avoid any further errors (including the undefined index). // verify nonce // if ( ! isset( $_POST[‘product_noncename’] ) || ! wp_verify_nonce( $_POST[‘goal_info_meta_box_nonce’], basename( __file__ ) ) ) { … Read more

WP_Query based on multiple metadata comparisons

You could split this into two WP_Querys: $args = array( ‘post_type’ => ‘match_report’, ‘post_status’ => ‘publish’, ‘meta_key’ => ‘report_type’, ‘meta_value’ => ‘cup’, ‘fields’ => ‘ids’ ); $reportsPre = new WP_Query($args); $post_IDs = array(); if(isset($reportsPre->posts) && !empty($reportsPre->posts)){ foreach((array) $reportsPre->posts as $id) { $post_IDs[] = $id; } } $args2 = array( ‘post__in’ => array($post_IDs), ‘meta_query’ => array( … Read more

Custom field in a shortcode?

$post is global variable, so it’s not visible in this scope (and when you use $post in your code, you’re not referring to global $post variable but to local one) You should put global $post somewhere in your code. For example like this: … while ($loop->have_posts()){ global $post; $loop->the_post(); $output .= ‘<li><a href=”‘.get_permalink().'”><img src=”‘.get_post_meta($post->ID,’wpcf-udstiller-logo’,true).'”/></a></li>’; } … Read more

WP Post Meta Box Field Not Showing Updated Field

There is problem in your show_the_meta_box() function you have used value attribute for the textarea field don’t use value attribute for textarea field. For more information on textarea atrributes visit this page. So the correct code show_the_meta_box() function is as shown in following. function show_the_meta_box() { global $meta_box_code, $post; echo ‘<input type=”hidden” name=”id_meta_box_nonce” value=”‘. wp_create_nonce( … Read more

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