Advanced Custom Fields: Post Object – Not returning data [closed]
Solved. I had a typo – line 10: $post_object = get_field(‘post_object’); should have had the name of my post object field ie: $post_object = get_field(‘myfieldname’);
Solved. I had a typo – line 10: $post_object = get_field(‘post_object’); should have had the name of my post object field ie: $post_object = get_field(‘myfieldname’);
Here is a simple way to do this: // First declare total and count before the loop $total = 0; $count = 0; foreach($posts as $post) { if(get_field(‘prod_fi’)){ // If we have a value add it to the total and count it $total += get_field(‘prod_fi’); $count++; } } echo ‘Count: ‘. $count; echo ‘Total Sum: … Read more
Argh..easy to fix: instead of include( ABSPATH . ‘wp-admin/includes/image.php’ ); use require_once( ABSPATH . ‘wp-admin/includes/image.php’ ); Hope this helps someone!
I don’t know of any WordPress-specific way to exclude duplicate-title posts from a query and I’m sure that there are multiple ways to address this. The solution that jumps to mind is to store each post title in an array and then check to see if that title is already there before outputting the post. … Read more
Here is what I ended up doing based on @gdaniel’s suggestion: AJAX call: $(‘.btn’).click(function() { $.ajax({ url:”<?php bloginfo(‘template_directory’); ?>/inc/galleries.php”, type: ‘POST’, data: {postID: ‘<?=$post->ID;?>’, galleryCategory: $(this).attr(“data-content”)}, success: function(resp) { $(‘#photos’).append(resp); } }); }); And here is my PHP file: <?php require(‘../../../../wp-load.php’); $postid = $_POST[‘postID’]; $galcat = $_POST[‘galleryCategory’]; ?> <div class=”photos” id=”$galcat”> <h1><?php echo $galcat; ?> … Read more
Just for information, this is a bug in WP and autop. You can view the ticket here and it does not look like it will be fixed any time soon. The work around is to start your multiline comment with <!– and end it with <!– –>
There’s no need for the custom meta SQL filter – the beauty of storing dates in the format Ymd is that you can treat them numerically, and MySQL will still be able to find events in a given “range” and sort them ascending/descending. I’ve done this recently on another site using ACF for start/end date: … Read more
I’ve just solved this issue thanks to the Avanced WordPress group in Facebook (https://www.facebook.com/groups/advancedwp/). It was actually a mistake I had made: I had a query before the custom fields and it had to be reset. This is the working snippet: <?php // WP_Query arguments $args = array ( ‘post_type’ => ‘post’, ‘posts_per_page’ => ‘4’, … Read more
Got it working in the end with the below code: <?php $args = array( ‘posts_per_page’=> -1, ‘post_type’ => ‘properties’, ‘meta_key’ => ‘development’, ‘meta_value’ => $development_id, ); $properties_query = new WP_Query( $args ); $prices = array(); if( $properties_query->have_posts() ): while( $properties_query->have_posts() ) : $properties_query->the_post(); $price = get_field(‘price’); if(isset($price) && !empty($price)){ $prices[] = $price; } endwhile; $max_price … Read more
As mentioned in the comments, you can use the Plugin and Metadata APIs to attach some functionality to the ‘profile_update’ action such that whenever a user’s profile information receives an update, custom user-metadata is set to the time of the update: function wpse216609_update_profile_modified( $user_id ) { update_user_meta( $user_id, ‘wpse216609_profile_updated’, current_time( ‘mysql’ ) ); } add_action( … Read more