do shortcode wordpress
<?php echo do_shortcode('[name_of_shortcode]'); ?>
do shortcode wordpress
<?php echo do_shortcode('[name_of_shortcode]'); ?>
wordpress shortcode
function wp_demo_shortcode() {
//Turn on output buffering
ob_start();
$code = 'Hello World';
ob_get_clean();
// Output needs to be return
return $code;
}
// register shortcode
add_shortcode('helloworld', 'wp_demo_shortcode');
wordpress shortcode
// function that runs when shortcode is called
function wpb_demo_shortcode() {
// Things that you want to do.
$message = 'Hello world!';
// Output needs to be return
return $message;
}
// register shortcode
add_shortcode('greeting', 'wpb_demo_shortcode');
php shortcode wordpress return content with shortcodes
return do_shortcode($content);
wp add shortcode for custom post type
function diwp_create_shortcode_movies_post_type(){
$args = array(
'post_type' => 'movies',
'posts_per_page' => '10',
'publish_status' => 'published',
);
$query = new WP_Query($args);
if($query->have_posts()) :
while($query->have_posts()) :
$query->the_post() ;
$result .= '<div class="movie-item">';
$result .= '<div class="movie-poster">' . get_the_post_thumbnail() . '</div>';
$result .= '<div class="movie-name">' . get_the_title() . '</div>';
$result .= '<div class="movie-desc">' . get_the_content() . '</div>';
$result .= '</div>';
endwhile;
wp_reset_postdata();
endif;
return $result;
}
add_shortcode( 'movies-list', 'diwp_create_shortcode_movies_post_type' );
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us