“Updating Failed” error inside WordPress Editor.
-
I’m getting “Updating Failed” inside Element when I’m using shortcode.
This is code of my shortcode
function shortcode_field_value( $atts ) { if ( ! is_admin() ) { $atts = shortcode_atts( array( 'field_name' => '', 'link' => false ), $atts, 'field_value' ); $post_id = get_the_ID(); if( ! $post_id ) { return ''; } $cache_key = 'field_value_' . $post_id . '_' . $atts['field_name']; $value = wp_cache_get( $cache_key ); if( false === $value ) { $value = get_field( $atts['field_name'], $post_id ); if( is_array( $value ) ) { $terms = array(); foreach( $value as $term ) { $terms[] = $term->name; } $value = implode( ', ', $terms ); } elseif( is_a( $value, 'WP_Term' ) ) { $value = $value->name; } wp_cache_set( $cache_key, $value, '', 3600 ); } if( $atts['link'] ) { $value = sprintf( '<a href="%s">%s</a>', get_term_link( $value ), $value ); } return $value; } } add_shortcode( 'field_value', 'shortcode_field_value' );
Please help me find solution for this error.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘“Updating Failed” error inside WordPress Editor.’ is closed to new replies.