如何从wordpress的自定义帖子类型插件中检索php中的图像和标题
如何从下面的代码中获取图像和标题的动态数据?我目前正在处理此代码,但无法检索数据。我附加的滑块屏幕截图没有显示,以及我也添加了演示滑块的屏幕截图 my front-page.php:如何从wordpress的自定义帖子类型插件中检索php中的图像和标题,php,wordpress,custom-post-type,Php,Wordpress,Custom Post Type,如何从下面的代码中获取图像和标题的动态数据?我目前正在处理此代码,但无法检索数据。我附加的滑块屏幕截图没有显示,以及我也添加了演示滑块的屏幕截图 my front-page.php: <?php $our_services = get_our_services_list(5); ?> <div class="col-sm-12"> <div class="our-services-slider">
<?php $our_services = get_our_services_list(5); ?>
<div class="col-sm-12">
<div class="our-services-slider">
<?php
if(!empty($our_services) && count($our_services) > 0){
for($i=0; $i<count($our_services); $i++) {
?>
<div class="slider-tile">
<div class="tile-img">
<img src="<?php echo $services_image; ?>" alt="">
</div>
<div class="tile-text">
<h4>
<b><?php echo $post_title; ?></b>
</h4>
<p><?php echo $post_excerpt; ?></p>
<div class="text-center">
<a class="btn btn-mehroon" href="<?php echo $services_button_link; ?>">
<?php echo $services_button; ?></a>
</div>
</div>
</div>
<?php } } ?>
演示页面
我的页面:
你应该试试这个:
<?php
$args = array(
'post_type' => 'client_testimonial',
'post_status' => 'publish',
'posts_per_page'=> 6,
'order' => 'DESC',
'orderby' => 'date'
);
$query = new WP_Query($args);
?>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
确定您处于while循环中,并尝试以下操作:echo获取标题$query->ID;或者您也只能使用:_标题;再次面临同样的问题您是否在该页面的任何位置使用了wp_查询?请共享您的全部代码以及自定义帖子类型详细信息
<?php
$args = array(
'post_type' => 'client_testimonial',
'post_status' => 'publish',
'posts_per_page'=> 6,
'order' => 'DESC',
'orderby' => 'date'
);
$query = new WP_Query($args);
?>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<?php $img = get_the_post_thumbnail_url(get_the_ID()); ?>
echo get_the_title(get_the_ID());