Wordpress 获取“post”meta-isn';不能在短码中返回任何内容
我正试图通过一个短代码向我的页面添加一组推荐信(自定义帖子类型)。短代码(如下所示)在页面上输出,它从创建的4个证明中提取4个条目。。。但是get\u post\u meta没有返回任何内容。不确定通过短代码处理post数据是否有什么我不知道的地方。有什么想法吗 网站位于penderair.yourbrandstorger.comWordpress 获取“post”meta-isn';不能在短码中返回任何内容,wordpress,custom-post-type,shortcode,Wordpress,Custom Post Type,Shortcode,我正试图通过一个短代码向我的页面添加一组推荐信(自定义帖子类型)。短代码(如下所示)在页面上输出,它从创建的4个证明中提取4个条目。。。但是get\u post\u meta没有返回任何内容。不确定通过短代码处理post数据是否有什么我不知道的地方。有什么想法吗 网站位于penderair.yourbrandstorger.com <?php /* Testimonial shortcode */ if (!function_exists('ybs_testimonials')) {
<?php
/* Testimonial shortcode */
if (!function_exists('ybs_testimonials')) {
function ybs_testimonials() {
$html = '<ul class="testimonials">';
$testimonials_arguments = array(
'post_type' => 'testimonial',
'posts_per_page' => 5
);
$testimonials_query = new WP_Query( $testimonials_arguments );
if ( $testimonials_query->have_posts() )
{
while ( $testimonials_query->have_posts() ) :
$testimonials_query->the_post();
$testimonial_content = get_post_meta($post->ID,'the_testimonial', true);
$testimonial_author = get_post_meta($post->ID,'testimonial_author', true);
$html .= '<li>';
if ( has_post_thumbnail() )
{
$html .= '<div class="imgbox">' . the_post_thumbnail('testimonial-thumb') . '</div>';
}
$html .= '<div class="detail">
<blockquote>
<p>' . $testimonial_content . '</p>
</blockquote>
<p class="author">' . $testimonial_author . '</p>
</div>
</li>';
endwhile;
}
$html .= '</ul>';
return $html;
}
}
add_shortcode('ybs_testimonials', 'ybs_testimonials');
对不起,问题已解决。只需要更改:$post->ID以获取我的get\u post\u元调用中的\u ID()