Last active
May 13, 2023 00:22
-
-
Save dantetesta/f7e5b0bf7c5bde5c956dfa03dbfaa7f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Text to HTML | |
Description: Converte um texto em HTML usando um shortcode [text_to_html field="nome_do_campo_meta"] | |
Version: 1.0 | |
Author: Dante Testa | |
*/ | |
function text_to_html_shortcode( $atts ) { | |
$atts = shortcode_atts( array( | |
'post_id' => get_the_ID(), | |
'field' => '', | |
), $atts, 'text_to_html' ); | |
$meta_value = get_post_meta( $atts['post_id'], $atts['field'], true ); | |
// Trata parágrafos e quebras de linha | |
$meta_value = wpautop( $meta_value ); | |
// Imprime o valor do metafield | |
return $meta_value; | |
} | |
add_shortcode( 'text_to_html', 'text_to_html_shortcode' ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment