我管理一个wordpress网站,并创建了一个模板部分,我通常将其粘贴在内容下方。
<div class="posts-group">
<h2>Featured store products</h2>
<?php $catquery = new WP_Query( \'post_type=product&posts_per_page=4&orderby=rand\' );
while($catquery->have_posts()) : $catquery->the_post();
?>
<a href="<?php echo get_post_meta($post->ID,\'PRODUCT-url\', true);?>">
<article class="post home-post homeproduct">
<div class="post-thumbnail-img">
<?php the_post_thumbnail(\'small-thumbnail\'); ?>
</div>
<h2><?php the_title(); ?></h2>
<p></p>
</article>
</a>
<?php endwhile; ?>
</div>
现在我想把它放在内容之间,所以我想使用一个短代码function get_products($atts) {
get_template_part(\'block-products-inline\');
}
add_shortcode(\'products\', \'get_products\');
现在,每次我发布[产品]时,我都希望这些产品会出现在那里。然而,当我尝试上面的代码时,products template\\u部分会一直到页面顶部,就在标题的正下方和实际内容的正前方。但是,当我编辑短代码只是返回一些文本时,文本确实会出现在内容的中间。
有人知道发生了什么吗?因为我没有。。