No me gusta hablar de Themes de WordPress que yo no uso, en parte porque la mayoría de esas plantillas son muy limitadas. Pero resulta que un cliente me ha pedido que le haga unos cambios en su plantilla, diseñada y configurada por el theme ENFOLD.
Pues bien, hay una parte del trabajo que consistía en cambiar las migas de pan que vienen con Enfold y poner las de Yoast SEO.
Tras mucha investigación encontré dos tickets de soporte en el foro de Enfold que me vinieron como anillo al dedo tras hacerles una pequeña modificación.
El código es el siguiente, y se pone en tu archivo functions.php de tu child theme:
//migas de pan de YOAST para Enfold Theme
if (!function_exists('avia_title')) {
function avia_title($args = false, $id = false)
{
global $avia_config;
if (!$id) $id = avia_get_the_id();
$header_settings = avia_header_setting();
if ($header_settings['header_title_bar'] == 'hidden_title_bar') return "";
$defaults = array(
'title' => get_the_title($id),
'subtitle' => "", //avia_post_meta($id, 'subtitle'),
'link' => get_permalink($id),
'html' => "{heading_html}{additions}",
'heading_html' => "{title}
",
'class' => 'stretch_full container_wrap alternate_color ' . avia_is_dark_bg('alternate_color', true),
'breadcrumb' => true,
'additions' => "",
'heading' => 'h1' //headings are set based on this article: http://yoast.com/blog-headings-structure/
);
if (is_tax() || is_category() || is_tag()) {
global $wp_query;
$term = $wp_query->get_queried_object();
$defaults['link'] = get_term_link($term);
} else if (is_archive()) {
$defaults['link'] = "";
}
// Parse incomming $args into an array and merge it with $defaults
$args = wp_parse_args($args, $defaults);
$args = apply_filters('avf_title_args', $args, $id);
//disable breadcrumb if requested
if ($header_settings['header_title_bar'] == 'title_bar') $args['breadcrumb'] = false;
//disable title if requested
if ($header_settings['header_title_bar'] == 'breadcrumbs_only') $args['title'] = '';
// OPTIONAL: Declare each item in $args as its own variable i.e. $type, $before.
extract($args, EXTR_SKIP);
if (empty($title)) $class .= " empty_title ";
$markup = avia_markup_helper(array('context' => 'avia_title', 'echo' => false));
if (!empty($link) && !empty($title)) $title = $title;
if (!empty($subtitle)) $additions .= "" . wpautop($subtitle) . "";
if($breadcrumb) $additions .= yoast_breadcrumb('','
', false);
if (!$title) $heading_html = "";
$html = str_replace('{heading_html}', $heading_html, $html);
$html = str_replace('{class}', $class, $html);
$html = str_replace('{title}', $title, $html);
$html = str_replace('{additions}', $additions, $html);
$html = str_replace('{heading}', $heading, $html);
if (!empty($avia_config['slide_output']) && !avia_is_dynamic_template($id) && !avia_is_overview()) {
$avia_config['small_title'] = $title;
} else {
return $html;
}
}
}
Y si quieres saber como llegué a éste código, visita los siguientes tickets de soporte de Enfold: