需要为其他页面上的显示帖子创建快捷码。短代码需要添加到wp编辑器中。
我为另一个页面上的显示帖子创建了以下代码:
<div class="owl-carousel-wrap jobs-carousel">
<div id="jobsCarousel" class="owl-carousel ">
<?php
$args = array(
\'post_type\' => array(\'job\')
);
$the_query = new WP_Query( $args );
?>
<?php global $post; ?>
<?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<?php if ( 683 !== $post->ID ) { ?>
<a href="<?php the_permalink(); ?>" class="jobs">
<?php } ?>
<div class="jobs-item">
<h2 class="page-head_sub-title"><?php the_title(); ?></h2>
<p><?php the_content(); ?></p>
</div>
<?php if ( 683 !== $post->ID ) { ?>
</a>
<?php } ?>
<?php endwhile; endif; ?>
</div>
<div class="js-control-jobs">
<div class="carousel-control-prev"><span class="icon-arrow"><!--icon--></span></div>
<div class="carousel-control-next"><span class="icon-arrow"><!--icon--></span></div>
</div>
</div>
它在php模板中按预期工作。但是如何在shortcode函数中添加此代码以供使用[jobs]
?