本文介绍了如何制作wordpress简码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个代码来显示所有类别的帖子和其中第一个帖子的缩略图.
I have this code to show all post of category and thumbnail for 1st post of them.
<?php $recent = new WP_Query(); ?>
<?php $recent->query( 'cat=1&showposts=5' ); ?>
<?php $is_first_post = true; ?>
<?php while( $recent->have_posts() ) : $recent->the_post(); ?>
<ul>
<li>
<?php
if ( $is_first_post && has_post_thumbnail() ) {
the_post_thumbnail();
$is_first_post = false;
}
?>
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</li>
</ul>
<?php endwhile; ?>
但我想使用简码显示这个.其中使用类别 &邮编但我不能制作短代码
but i want show this using shortcode.which using category & post numberbut i can not make shortcode
推荐答案
function ShowProduct()
{
$data = "Welcome to wordpress shortcode.";
return $data;
}
add_shortcode('products', 'ShowProduct');
http://www.codexwp.com/问题/如何在wordpress中创建简码/
这篇关于如何制作wordpress简码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!