Add up all numbers from a WordPress query [closed]

.= does string concatention, eg, ‘hello ‘ . ‘world’ gets you hello world. To add, use + instead of .: // Set a default for $numbers. $numbers = 0; $query = new WP_Query($args); if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $post_id = get_the_ID(); $party_size = get_field(‘reservation_party_size’, $post_id); $numbers += intval( $party_size ); } } return … Read more

Randomize post list with some posts with specific ACF value in the top 50%

Issue with the way you are unsetting sticky posts from the $post_list array and then reinserting them at the specified positions and should work correctly like below code structure. Removed the unnecessary $position variable in the foreach loop. Changed the way sticky items are inserted back into the $post_list array using array_unshift to add them … Read more

Generate Post Title From ACF Fields on Custom Post Type

I just wanted to post the code that got this working without issues. I had an extra argument in the function that was never being used ( $post ). function ccc_acf_update_fixture_post_title( $post_id ) { if ( get_post_type( $post_id ) == ‘fixture’ ) { $team = get_field( ‘team’, $post_id ); $venue = get_field( ‘venue’, $post_id ); … Read more

Replace multiple RichText components in a single block – wp.blockEditor.RichText multiline prop is deprecated

Now I can’t replace these with InnerBlocks as Innerblocks can only be used once in a block A HTML tag has this same restriction yet it hasn’t stopped this from being done, the answer is composition. The core/columns block has this same problem and solves it by only allowing individual core/column blocks as its children, … Read more

Date not working correctly

What you did wrong here is the part date(‘d’, $rem_days). The function date() should be used to convert timestamp to a formatted date, not to converting a time difference in timestamp to time difference in days. You can fix this by replacing date(‘d’, $rem_days) with floor($rem_days/86400). The complete code should be: $event_date = strtotime( get_field( … Read more