New answers tagged

0

The most probable route I will take with this is to run a script that would add the desired custom field to the posts which does not have the custom field assigned. You can try the following: (NOTE: This is untested) add_action( 'wp', function () { $args = [ 'post_type' => 'post', // Set according to needs 'posts_per_page' ...


1

You can get both with an OR meta_query that also checks if the key does not exist: 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'event_date', 'compare' => 'NOT EXISTS', ), array( 'key' => 'event_date', 'value' => date("Ymd", time()), 'compare' => '>', ), ), ...


0

I got it! For any one in the future with the same problem: ACF's get_field_object() apparently makes a WP_Query and doesn't clean up after so, since I called it for every post, I always got the same post after a certain point in the elaboration. I found the solution in this question. Some code for clarity: <?php while ( $query->have_posts() ) : ...


0

Have you tried using wp_reset_query() before the loop.


-1

I sorted this out, $post should be $p in: global $post; $product = new WC_Product( $post->ID );


1

For every meta value saved there is a second row prefixed with _ that stores what field definition this value refers to. Do not delete it. Your example additionally is a repeater which makes it more complex but the docs has a nice explanation: $ParentName_$RowNumber_$ChildName So you have a repeater field called carousel which has a subfield called ...


0

I've ruled out this being an issue with Advanced Custom Fields, so I've made a new question. For more information, please look at: wp_get_attachment_image_src multisite issue


0

If you want to be able to sort the columns you will need the pro version. This is not supported in the free version!


1

At first - do not use extract. It's very bad code style and is also depracated in core. Every time your foreach loop run, you override content of $output because you assign to this variable new content. What you want is to concatenate new list item with existing ones. This can be done using concatening assignment operator: $output .= '<li ...


3

Hook into the body_class filter and add your field there. It might be better to get the ID from get_queried_object_id() instead of get_the_ID(). add_filter( 'body_class', 'wpse_20160118__body_class' ); function wpse_20160118__body_class( $classes ) { if ( $package_colour = get_field( 'package_colour', get_queried_object_id() ) ) { ...


0

A much shorter solution, just add this before foreach: usort($terms, function($a, $b) { return get_field('issue_date', $a) - get_field('issue_date', $b); });



Top 50 recent answers are included