Complex WP_Query Using Post Date And Post Meta
Complex WP_Query Using Post Date And Post Meta
Complex WP_Query Using Post Date And Post Meta
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
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
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
You should use get_post_meta($sidans_id, ‘kund’, true); instead. The get_field call is using the ID from the post loop and not from global.
you need to add the same code for displaying “custom title” into your single.php like this $custom_title = get_post_meta($post->ID,’custom fields name’,true); echo $custom_title;
Meta fields are heavily cached. Depending on your configuration and specific query, it is likely that WP_Query calls update_post_caches() which trickles down to update_meta_cache() for queried posts. Most of the time you don’t need to worry about this, until you determine that it is real bottleneck in some way (like profiling code).
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
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
$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