Custom fields: Split data from single custom field’s sub-array to separate custom fields when saving post
Custom fields: Split data from single custom field’s sub-array to separate custom fields when saving post
Custom fields: Split data from single custom field’s sub-array to separate custom fields when saving post
Automatically delete posts that aren’t in an array
JSON webhook WP Automator – Help with Syntax [closed]
This is probably more a question about PHP rather than WordPress, and as such may be closed as off-topic for this site. That said, you can usort() to sort an array using a custom comparison function: usort( $listings->loop[‘cats’], function( $a, $b ){ return strlen( $a->name ) – strlen( $b->name ); } ); After the call … Read more
The value you’re trying to send in the body is not valid JSON: { “userID” = 3 } JSON looks like this: { “userID”: 3 }
Firstly, this isn’t a WordPress error. It’s a PHP error. WordPress is not going to return type errors. That all happens and the language level. If you used the same values outside of WordPress you’d get the same error. Regarding your specific issue, keep in mind that get_terms() will return a WP_Error object if the … Read more
You’re getting the Fatal Error because array_diff() is comparing the WP_Term objects in your array to a string, and it can’t do that. Here’s one way to fix that: Replace $topic = array_diff($topic, [“expired”]); with: $my_topic = array(); foreach ( $topic as $term ) { if ( ‘expired’ !== $term->slug ) { // Adds $term … Read more
There are a few ways you can make an integer a string. Here are 2 main ways to make that happen Type Cast – $values_x[] = (string) $series[0][‘data’][$i][0] Double Quote – $values_x[] “{$series[0][‘data’][$i][0]}” Also, you might want to check for null first and assign a default $values_x = !empty($values_x) ? $values_x : array(‘2010’); If you … Read more
It looks like you are using Advanced Custom Fields. Your “Product ID” is storing the object, instead of just the ID. Below shows you how you can access the post ID, otherwise just change your field saving option for Product ID. It’s a simple foreach statement. foreach( $pages as $page ) { echo $page[‘product_id’]->ID; }
Assuming that you have an array of post objects in $my_posts… $authids = array_unique(wp_list_pluck($my_posts,’post_author’)); What you will get are the post authors for the current page of posts, not the post authors for all of the posts. If you want the authors for all of the posts you will have run another query. To run … Read more