Differenze tra le versioni di "Shortcode personalizzati WordPress"
m |
|||
| Riga 1: | Riga 1: | ||
| − | [[ | + | [[WordPress|← ritorno a WordPress]] [[Category:WordPress]] |
== Vedi anche ... == | == Vedi anche ... == | ||
Versione attuale delle 07:35, 30 mar 2023
Vedi anche ...
Includere il contenuto di una pagina in un'altra pagina o area di testo
/**
* SHORTCODE per includere il contenuto di una pagina in un'altra pagina o area di testo;
* shortcode da inserire: [myshrt_postcontent id=""]
*/
function myshrt_postcontent_func( $atts ) {
if( ! array_key_exists( 'id', $atts ) )
return '';
if( empty( $atts['id'] ) )
return '';
$content_post = get_post( $atts['id'] );
if( empty( $content_post ) )
return '';
$content = apply_filters('the_content', $content_post->post_content );
$content = str_replace(']]>', ']]>', $content);
return $content;
}
add_shortcode( 'myshrt_postcontent', 'myshrt_postcontent_func' );