/*
Theme Name: Enfold Child
Description: A <a href='http://codex.wordpress.org/Child_Themes'>Child Theme</a> for the Enfold Wordpress Theme. If you plan to do a lot of file modifications we recommend to use this Theme instead of the original Theme. Updating wil be much easier then.
Version: 1.0
Author: Kriesi_Almu
Author URI: http://www.lamissio.org
Template: enfold
*/



/*Add your own styles here:*/

// Cambiar el enlace de la entrada por uno personalizado
add_filter('post_link', 'cambiar_enlace_por_campo_personalizado', 10, 2);
function cambiar_enlace_por_campo_personalizado($url, $post) {
    // Buscamos si existe el campo 'url_destino'
    $custom_url = get_post_meta($post->ID, 'url_destino', true);
    
    // Si el campo tiene contenido, devolvemos esa URL
    if (!empty($custom_url)) {
        return $custom_url;
    }
    
    return $url;
}


add_filter( 'avf_customize_setting_extract', 'cambiar_texto_leer_mas', 10, 1 );
function cambiar_texto_leer_mas( $excerpt ) {
    return str_replace('Read more', '¡APUNTARME YA!', $excerpt);
}

// Alternativa más robusta para Enfold
add_filter('avf_excerpt_read_more_link', 'nuevo_texto_boton_enfold');
function nuevo_texto_boton_enfold($link) {
    return " <a href='".get_permalink()."' class='more-link'>¡APUNTARME YA!</a>";
}