En el functions.php (o con Code Snippets si quieres) del tema activo:
function add_shortcode_todos_los_posts( $content ) {
global $post;
if( ! $post instanceof WP_Post ) return $content;
switch( $post->post_type ) {
case 'post':
return $content . '[metaslider id="127"]';
case 'page':
return $content . '[metaslider id="127"]';
default:
return $content;
}
}
add_filter( 'the_content', 'add_shortcode_todos_los_posts' );
También lo puedes hacer creándote tu propio plugin el cual luego activas (te creas con el FTP la carpeta en plugins y dentro de dicha carpeta el fichero, por ejemplo: lsg-add-shortcode-all-posts.php y el código será:
<?php
/*
Plugin Name: LSG add shortcode all posts
Plugin URI: http://your-url.com
Description: Añade el shortcode del slider a todos tus posts y pages
Version: 0.1
Author: Leandro Sierra García
Author URI: http://www.leandrosierragarcia.com
*/
function add_shortcode_all_posts( $content ) {
global $post;
if( ! $post instanceof WP_Post ) return $content;
switch( $post->post_type ) {
case 'post':
return $content . '[metaslider id="127"]';
case 'page':
return $content . '[metaslider id="127"]';
default:
return $content;
}
}
add_filter( 'the_content', 'add_shortcode_all_posts' );
?>
Luego activas desde el Admin este nuevo plugin y ya está.

No hay comentarios:
Publicar un comentario