您可以为元框数据尝试以下操作:
使用以下内容查询元数据:
<?php
$slider = new WP_Query(array(
\'post_type\' => \'post\',
\'posts_per_page\' => 5,
\'post_status\' => \'publish\',
\'meta_query\' => array(
array(
\'key\' => \'your metabox key\',
\'value\' => \'your metabox value\',
\'compare\' => \'IN\'
)
)
));
if($slider->have_posts()) :
while($slider->have_posts()) : $slider->the_post();
$idd = get_the_ID();
?>
<?php echo get_excerpt(); ?>
<?php
endwhile;
endif;
?>
并将此代码放入函数中。php:
function get_excerpt(){
$excerpt = get_the_content();
$excerpt = preg_replace(" (\\[.*?\\])",\'\',$excerpt);
$excerpt = strip_shortcodes($excerpt);
$excerpt = strip_tags($excerpt);
$excerpt = substr($excerpt, 0, 820);
$excerpt = substr($excerpt, 0, strripos($excerpt, " "));
$excerpt = trim(preg_replace( \'/\\s+/\', \' \', $excerpt));
$excerpt = $excerpt.\'.... <a href="\'.get_permalink().\'" class="read_more"><h4 style="margin:0;">Details</h4></a>\';
return $excerpt;
}