Support

Account

Home Forums General Issues How to use WP Term Meta, the easy way! Reply To: How to use WP Term Meta, the easy way!

  • @truheart

    Good idea to automate! I just would use “termmeta_” as the prefix, makes it more reliable to avoid mistakes and put the filter after check field name.

    function ...( $value, $post_id, $field ) {
    	if( strpos( $field['name'], 'termmeta_' ) === 0 ) {
    		$term_id = intval( filter_var( $post_id, FILTER_SANITIZE_NUMBER_INT ) );
    		if( $term_id > 0 )
    			[...]
    	}
    	return $value;
    }