这是我的自定义邮政编码,任何人都可以指导我如何获得其短代码实际上我想在我的主页上调用我使用avada主题和avada主题使用“Fusion Builer”如何显示我的主页??
//在“function.php”中 //推荐自定义帖子
add_action( 'init', 'create_testimonial' );
function create_testimonial() {
register_post_type( 'testimonial',
array(
'labels' => array(
'name' => 'Testimonial',
'singular_name' => 'Testimonial',
'add_new' => 'Add New',
'add_new_item' => 'Add New Testimonial',
'edit' => 'Edit',
'edit_item' => 'Edit Testimonial',
'new_item' => 'New Testimonial',
'view' => 'View',
'view_item' => 'View Testimonial',
'search_items' => 'Search Testimonial',
'not_found' => 'No Movies found',
'not_found_in_trash' => 'No Movies found in Trash',
'parent' => 'Parent Testimonial'
),
'public' => true,
'menu_position' => 15,
'supports' => array( 'title', 'editor', 'comments', 'thumbnail', 'custom-fields' ),
'taxonomies' => array( '' ),
'menu_icon' => plugins_url( 'images/image.png', __FILE__ ),
'has_archive' => true
)
);
}
//在我的Eidtior当我打电话给POst时
<?php
$query = new WP_Query( array('post_type' => 'testimonial', 'posts_per_page' => 4 ) );
while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="post_area">
<div class="post_thumb">
<?php echo the_post_thumbnail(); ?>
</div>
<div class="post_txt">
<div class="post_cntnt"><?php the_content(); ?></div>
<div class="post_title"><?php the_title(); ?></div>
</div>
<div class="clear"></div>
</div>
<?php endwhile; ?>
答案 0 :(得分:0)
从Wordpress codex中读取短代码API。
https://codex.wordpress.org/Shortcode_API
您只需要一行代码:
add_shortcode( 'testimonial', 'create_testimonial' );
将此行放在您的函数下,您可以使用这样的短代码:
[testimonial]