如何使用中继框?

时间:2019-07-30 11:39:53

标签: php wordpress

我使用meta,并且可以在wordpress中使用,但无法在网站中显示值

$tecno_testimonial_post =new WP_Query(
             array(
             'post_type'=>'testimonial',
               'posts_per_page'=> $testimonial_count,  ));

 if($tecno_testimonial_post ->have_posts()):while($tecno_testimonial_post ->have_posts()):$tecno_testimonial_post ->the_post(); ?>


<div class="testimonial-block-two col-lg-6 col-md-12 col-sm-12">
<div class="inner-box">
<div class="upper-box">
<div class="quote-icon flaticon-two-quotes"></div>  <div class="author-info">
<h3>
<?php $my_meta = get_post_meta($post->ID, '_my_meta',true); ?>
<?php if(isset($my_meta['customer']) && !empty($my_meta['customer'])) : ?>
<?php echo $my_meta['customer']; ?>
<?php endif; ?>
</h3>
<div class="designation">
<?php $my_meta = get_post_meta($post->ID, '_my_meta',true); ?>
<?php if(isset($my_meta['position']) && !empty($my_meta['position'])) : ?>
<?php echo $my_meta['position']; ?>
<?php endif; ?>

它无法显示客户和网站位置

1 个答案:

答案 0 :(得分:0)

<?php
            $tecno_testimonial_post =new WP_Query(
                  array(
                  'post_type'=>'testimonial',
                  'posts_per_page'=> $testimonial_count,
                  ));

                  if($tecno_testimonial_post ->have_posts()):while($tecno_testimonial_post ->have_posts()):$tecno_testimonial_post ->the_post();
                  ?>
            <!-- Testimonial Block Two -->
            <?php $id = get_the_ID();

            ?>

            <div class="testimonial-block-two col-lg-6 col-md-12 col-sm-12">
                <div class="inner-box">
                    <div class="upper-box">
                        <div class="quote-icon flaticon-two-quotes"></div>
                        <div class="author-info">
                            <h3>

                            <?php $my_meta = get_post_meta($id, '_my_meta',true); ?>

                            <?php if(isset($my_meta['customer']) && !empty($my_meta['customer'])) : ?>
                            <?php echo $my_meta['customer']; ?>
                            <?php endif; ?>

                            </h3>