对于shortcode,您可以使用Wordpress主题函数的add\\u shortcode函数。php。
function shortcode_video_slider()
{
?>
<div class="cr-carousel">
<?php
$loop = new WP_Query( array( \'post_type\' => \'video_slider\') ); //Change video_slider with your custom post name.
if ( $loop->have_posts() ) :
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div>
<?php if ( has_post_thumbnail() ) { ?>
<div class="pimage">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
</div>
<?php } ?>
<div class="cr-slider-content">
<div class="ptitle">
<?php
$terms = get_the_terms( get_the_ID() , \'video_slider_tex\' );
// Loop over each item since it\'s an array
if ( $terms != null ){
foreach( $terms as $term ) {
?>
<h2><a href="<?php the_permalink(); ?>"><?php echo $term->name; ?></a></h2>
<?php
unset($term); } }?>
</div>
<div class="cr-video-link">
<?php
$cr_video_link = get_post_meta( get_the_ID(), \'video_link\', true );
echo \'<a target="_blank" href="\' . $cr_video_link . \'" class="wplightbox" title="WordPress Carousel Plugin" data-width="1024" data-height="576">YouTube Lightbox</a>\';
?>
</div>
<div class="cr-video-cat">
<div class="cr-slide-category"><span> For</span> <a href="<?php the_permalink(); ?>"><?php echo get_the_title(); ?></a></div>
</div>
</div>
</div>
<?php endwhile;
if ( $loop->max_num_pages > 1 ) : ?>
<div id="nav-below" class="navigation">
<div class="nav-previous"><?php next_posts_link( __( \'<span class="meta-nav">←</span> Previous\', \'domain\' ) ); ?></div>
<div class="nav-next"><?php previous_posts_link( __( \'Next <span class="meta-nav">→</span>\', \'domain\' ) ); ?></div>
</div>
<?php endif;
endif;
wp_reset_postdata();
?>
</div>
<?php
}
add_shortcode(\'custom_video_slider\',\'shortcode_video_slider\');
现在您可以使用
[custom_video_slider]
无论您想在何处显示帖子。