Created
January 16, 2019 08:20
-
-
Save acanza/3705b45c23f05c6f902ca434477053d2 to your computer and use it in GitHub Desktop.
Shorcode para aplicar estilo a la caja de post invitado
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
| //* Shorcode para aplicar estilo a la caja de post invitado | |
| add_filter( 'the_content', 'shortcode_unautop', 100 ); | |
| add_shortcode( 'guest_post_box', 'guest_posts_shortcode'); | |
| function guest_posts_shortcode( $atts, $content = null ){ | |
| $output = ''; | |
| if ( !is_home() ) { | |
| $output = '<div class="guest-posts-box">'; | |
| $output .= do_shortcode( $content ); | |
| $output .= '</div>'; | |
| } | |
| return $output; | |
| } | |
| // Elimina las etiquetas de párrafo vacías de inicio y fin de los shortcodes | |
| add_filter( 'the_content', 'shortcode_empty_paragraph_fix' ); | |
| function shortcode_empty_paragraph_fix( $content ) { | |
| // define your shortcodes to filter, '' filters all shortcodes | |
| $shortcodes = array('guest_post_box' ); | |
| foreach ( $shortcodes as $shortcode ) { | |
| $array = array ( | |
| '<p>[' . $shortcode => '[' .$shortcode, | |
| '<p>[/' . $shortcode => '[/' .$shortcode, | |
| $shortcode . ']</p>' => $shortcode . ']', | |
| $shortcode . ']<br />' => $shortcode . ']' | |
| ); | |
| $content = strtr( $content, $array ); | |
| } | |
| return $content; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment