Notice: Trying to get property ‘term_id’ of non-object
I deleted problematic entries from wpgy_terms on database then it works now.If you are new at database, I suggest that backup your database before do something on it.
I deleted problematic entries from wpgy_terms on database then it works now.If you are new at database, I suggest that backup your database before do something on it.
Toolset Types display custom term field
Issue #1 (nested tax_query with OR relation) After going through WordPress core and WooCommerce core, it appears query_type_bag-type=or (query_type_.$attribute) query arg is only changing the value of the operator key on the individual taxonomy array for the attribute. For example: query_type_pa_color=and = operator => ‘AND’ query_type_pa_color=or = operator => ‘IN’ You can see in the … Read more
Replace following line $result .= ‘echo do_shortcode()’; with $result .= do_shortcode(”); Echo the result of function <p><?php echo first_audio(); ?></p>
AFAIK there’s no way to achieve that within a single WP_Query, so you’ll have to first get a list of term_ids which have a different year than the one in question. I think with the following you’ll come quite close. (don’t have a env to test right away) $other_years_terms = get_terms( ‘taxonomy’ => ‘vintage’, ‘meta_key’ … Read more
the order doesn’t seem to follow the meta value Yes, and it’s because you set the meta key like this: (which doesn’t actually set the meta key) array( ‘key’ => ‘order’, ), The proper way is by using the meta_key parameter: ‘meta_key’ => ‘order’ So the full code would be: $type_terms = get_terms( ‘type’, array( … Read more
The get_callback part is generated within the WP_REST_Controller::add_additional_fields_to_object() method with: $object[ $field_name ] = call_user_func( $field_options[‘get_callback’], $object, $field_name, $request, $this->get_object_type() ); That means the callback has four input arguments: ‘get_callback’ => function ( $object, $field_name, $request, $object_type ) { // … } and for the requested category object, we can get the term id with: … Read more
Try This: $args = array( ‘hide_empty’ => false, // also retrieve terms which are not used yet ‘meta_query’ => array( array( ‘key’ => ‘feature-group’, ‘value’ => ‘kitchen’, ‘compare’ => ‘LIKE’ ) ), ‘taxonomy’ => ‘category’, ); $terms = get_terms( $args );
Inserting boolean term meta values When we add non-existent term meta with e.g. add_term_meta( 123, ‘test’, true ); then we are actually running the following insert : $wpdb->insert( ‘wp_termmeta’, array( ‘term_id’ => 123, ‘meta_key’ => ‘test’, ‘meta_value’ => true ) ); within the general add_metadata() function. Now wpdb::insert() is actually a wrapper for wpdb::_insert_replace_helper() that … Read more
I think you need an update_callback in register_rest_field(). Please note that I haven’t tested this. add_action( ‘rest_api_init’, ‘slug_register_meta’ ); function slug_register_meta() { register_rest_field( ‘place’, ‘meta’, array( ‘get_callback’ => ‘slug_get_meta’, ‘update_callback’ => ‘slug_update_meta’, ‘schema’ => null, ) ); } function slug_get_meta( $object, $field_name, $request ) { return get_term_meta( $object[ ‘id’ ] ); } function slug_update_meta($value, $object, … Read more