moonorongo
4/27/2017 - 1:44 PM

[shortcodes WP] Ejemplos de Shortcode en wordpress #wordpress #php

[shortcodes WP] Ejemplos de Shortcode en wordpress #wordpress #php

add_shortcode( 'qbf_capital_cover', array( $this, 'qbf_capital_cover_html' ) );

public function qbf_capital_cover_html( $atts , $content) {

        $content = wpb_js_remove_wpautop($content, true);
        
        extract(
            shortcode_atts(
                array(
                    'image' => '',
                    'text'   => '',
                    'height' => '50vh',
                ), 
                $atts
            )
        );

        $img_html = wp_get_attachment_image( $image, 'full');
        $img_src = wp_get_attachment_image_src( $image, 'full');
        $img_src_height = $img_src[2];

        $html = '
                <header class="qbf-intro-container portfolio-title style1 entry-header" style="min-height:'.$img_src_height.'px" >
                    <div class="qbf-intro-image-container">'
                    . $img_html .           
                    '</div>
                    <div class="qbf-intro-text"  style="text-align: left">
                        <h1 class="entry-title" itemprop="name headline">' . get_the_title()  . '</h1>
                        <div class="qbf-list-text">' . $text . '</div>
                    </div>
                </header>';
            
        return $html;
}
<?php 
// cuando queremos mostrar content con shortcodes 

 do_shortcode(post_content);