If category then echo a custom fields

Use the in_category() function, like this: <?php if ( in_category( 4 ) ) : ?> <div class=”event-post-icons”> <ul> <li class=”single-post-date”><?php the_field(‘event_date’); ?></li> <li class=”single-post-time”><?php the_field(‘event_time’); ?></li> <li class=”single-post-price”><?php the_field(‘booking_fee’); ?></li> <li class=”single-post-palce”><?php the_field(‘event_location’); ?></li> </ul> </div><!– /event-post-icons –> <?php endif; ?> If you are using this to test a post outside of The Loop, you … Read more

Query post order by post and desc not working

post is not a valid value for orderby parameter neither DESC. You can choose any of these values. Also, you should stop using query_post. <?php $args = array( ‘post_type’ => ‘ranking’, ‘orderby’ => ‘menu_order’, ‘order’ => ‘DESC’, ‘posts_per_page’ => 10, ‘meta_key’ => ‘top10’, ‘meta_value’ => ‘sim’ ); $loop = new WP_Query( $args ); while ( … Read more

Use custom field as a variable

You are using the_ID() instead of get_the_ID(). Which is being echo. Also why you are using so many variable and pulling all the meta keys. I would like to suggest this code using get_post_meta(). $my_custom_field = get_post_meta(get_the_ID(), ‘app_collection-postcode’, true); $my_custom_field2 = get_post_meta(get_the_ID(), ‘app_delivery-postcode’, true); $url = “http://maps.googleapis.com/maps/api/distancematrix/json?origins=$my_custom_field&destinations=$my_custom_field2&mode=driving&language=en-EN&sensor=false”; $data = @file_get_contents($url); $result = json_decode($data, true); foreach($result[‘rows’] … Read more

Json api does not return all metadata

As @TheDeadMedic mentioned the API will exclude any meta with underscore. It’s not a good idea to remove the underscore as it might break something in your code or dependencies, however you can try adding a code like this in your functions.php to unprotect the desired meta add_filter( ‘is_protected_meta’, ‘wp692_meta_unprotect’, 10, 2 ); function wp692_meta_unprotect( … Read more

Metabox will not save

<input type=”number” name=”listing_price” id=”listing-price” value=”<?php if ( ! empty ( $cns_stored_meta[‘listing_price’] ) ) { echo esc_attr( $cns_store_meta[‘listing_price’][0] ); } ?>”/> You forget to put “d” where you echo your listing price. You also not write code for listing_description for save listing editor content. if( isset( $_POST[‘listing_description’] ) ) { update_post_meta( $post_id, ‘listing_description’, sanitize_text_field( $_POST[ ‘listing_description’ … Read more

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