ccc

Wordpress: Hooks

Esta web es muy interesante para localizar todos los Hooks que existen: www.hookr.io
Para buscar en la web todos los hooks darle arriba del todo a "Core" y luego ya buscar filtrando.

Desde code snippets creas uno nuevo:
// con esta funcion añado un nuevo meta al head
function add_new_meta_al_head() {
echo "<meta name='lsg' content='lsg'>";
}

add_action("wp_head", "add_new_meta_al_head", 10,0);


Ejemplo para filtrar contenido y poder modificarlo.

Desde Code snippets creamos uno nuevo:
// este ejemplo add más texto a cada uno de los post de la web
function filter_the_content( $post_post_content ) {
    // make filter magic happen here...
    return $post_post_content." y esto lo añado yo por mi cuenta";
};
       
// add the filter
add_filter( 'the_content', 'filter_the_content', 10, 1 );

No hay comentarios:

Publicar un comentario