Performance when getting post meta for post retrieved by meta value
When you call get_posts WP will also retrieve and cache all the post meta, so your later calls to get the meta data shouldn’t cause any more database queries.
When you call get_posts WP will also retrieve and cache all the post meta, so your later calls to get the meta data shouldn’t cause any more database queries.
This is how meta_key/_values work. How you store your values is case sensitive. Example meta_key = “foo’ and meta_value=”Bar” Would return the result you are looking for: $posts = new WP_Query( ‘post_type=post&meta_key=foo&meta_value=Bar’ ); Would not return the result you are looking for: $posts = new WP_Query( ‘post_type=post&meta_key=foo&meta_value=bar’ ); However it does appear that your database … Read more
Are you outputting the saved data to the edit post page before saving the post? If not you may be getting a empty $_POST[‘collection-topics’] data and then saving empty or null data. I would do a check before doing add_post_meta() if ( empty($_POST[‘collection-topics’]) ) return;
You need to get the title for each post ID in your array. The straightforward way is this: $procedure_title_list = array(); $procedure_list = get_post_meta($patient_story->ID, ‘Procedure’, false); foreach ( $procedure_list as $procedure ) { $procedure_title_list[] = get_the_title( $procedure ); } echo implode( ‘, ‘, $procedure_title_list );
You should modify the page templates directly or as a child theme in order to remove the items you don’t want visible. CSS could hide some portions visible to the user but the data is still written to the page by PHP. Google will still see it. Another thing to note is PHP doesn’t render … Read more
So I figured this out almost immediately after posting this question (duh) function business_facts_output( $post ) { //so, dont ned to use esc_attr in front of get_post_meta $business_facts_value= get_post_meta($_GET[‘post’], ‘business_facts’ , true ) ; wp_editor( htmlspecialchars_decode($business_facts_value), ‘business-facts’, $settings = array(‘textarea_name’=>’business-facts’) ); } Basically this bit here, where it says htmlspecialchars_decode($business_facts_value) needs to be changed. the … Read more
Sometimes one just needs to ask to understand what the issue is. DELETE FROM `db_name`.`wp_postmeta` WHERE `wp_postmeta`. `meta_key` LIKE ‘_field_name[%]’ did the trick.
Here you can just save the info in array and save that array in your post meta. some thing like this will work; $key = ‘save-author-to-book’; $values_to_save = array(); $new_values = $_POST[“save-author-to-book”]; $existing_values = get_post_meta( $post_id, $key, true ) ; if(!empty($existing_values)){ foreach($existing_values as $existing_value){ $values_to_save[] = $existing_value; } } if(!empty($new_values)){ foreach($new_values as $new_value ){ $values_to_save[] … Read more
Like @Dan9 said, you have a new line inside your value attribute. you can write your conditional statement this way too <div class = “meta-td03″> <input type=”text” class=”dwwp-row-content03″ name=”bonus_point” id=”bonus_point” value=”<?php ! empty( $dwwp_stored_meta[‘bonus_point’] ) ? echo esc_attr($dwwp_stored_meta[‘bonus_point’][0] ) : ”; ?>” /> </div>
Because “institute” is a user and you want to perform some actions when it is deleted, you could use delete_user action (as we need information of the deleted user, deleted_user may not work, not sure about this but delete_user should work for sure). In that hook you can get all users and posts based on … Read more