首页 > 解决方案 > 如何使用元框?

问题描述

我使用元,它在 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; ?>

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

标签: phpwordpress

解决方案


<?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>

推荐阅读