这是我尝试的方式,但不起作用
function blogPost(){
return ?>
<section class="blog container spacer">
<article class="blog__list">
<div class="glide-blog">
<div class="glide__arrows" data-glide-el="controls">
<button class="glide__arrow glide__arrow--left" data-glide-dir="<"><</button>
<button class="glide__arrow glide__arrow--right" data-glide-dir=">">></button>
</div>
<div class="glide__track" data-glide-el="track">
<ul class="glide__slides">
<?php
$the_query = new WP_Query( \'posts_per_page=3\' ); ?>
<?php
// Start our WP Query
while ($the_query -> have_posts()) : $the_query -> the_post();
?>
<li class="glide__slide"><?php the_post_thumbnail(\'medium\'); ?>
<a href="<?php the_permalink() ?>" class="new-article__main-title"><?php the_title(); ?></a>
</li>
<?php
// Repeat the process and reset once it hits the limit
endwhile;
wp_reset_postdata();
?>
</ul>
</article>
</section>
<?php
}
add_action(\'blog-shortcode\',\'blogPost\');