function custom_taxonomy_shortcode($atts) { ob_start(); $atts = shortcode_atts( array( 'taxonomy' => 'opciones_estandar', 'post_id' => get_the_ID() ), $atts ); $terms = get_the_terms($atts['post_id'], $atts['taxonomy']); echo '
'; if ($terms) { foreach ($terms as $term) { echo '
'; $image = get_field('imagen_taxonomia', $atts['taxonomy'] . '_' . $term->term_id); if ($image) { $ancho_formato = get_field('ancho_formato', $atts['taxonomy'] . '_' . $term->term_id); $ancho_estilo = $ancho_formato ? ' style="width:' . esc_attr($ancho_formato * 2) . 'px;"' : ''; echo '' . $term->name . ''; } if (get_field('texto_a_mostrar', $atts['taxonomy'] . '_' . $term->term_id)) { echo '

' . get_field('texto_a_mostrar', $atts['taxonomy'] . '_' . $term->term_id) . '

'; } else { echo '

' . $term->name . '

'; } echo '
'; } } echo '
'; return ob_get_clean(); } add_shortcode('custom_taxonomy', 'custom_taxonomy_shortcode');