0

Plugin More Fields を使用して、ページにコンテンツを表示しています。しかし、フィールド「チェックボックス」は機能しません。

<!-- Widget Productos destacados / Featured products -->
    <div id="cdm_carrusel">
        <ul>
            <?php
            $featuredprod = new WP_Query();
            $featuredprod->query('posts_per_page=3&post_type=products');
            while($featuredprod->have_posts()) {
                $featuredprod->the_post();
            ?>
                <!--if checkbox is checked, display list-->
                <?php if (meta('producto-destacado')) { ?>
                    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
                <!--else, if not checked, don't display content-->
                <?php } else { ?>
                    <!--Nothing -->
                <?php } ?>
            <?php
            }           
            ?>
        </ul>
    </div>
    <!-- // Widget Productos destacados / Featured products -->

何か提案はありますか?

ありがとう :)

4

1 に答える 1

0

これを置き換えます:

<!--if checkbox is checked, display list-->
     <?php if (meta('producto-destacado')) { ?>
      <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
      <!--else, if not checked, don't display content-->
      <?php } else { ?>
          <!--Nothing -->
      <?php } ?>

これとともに:

<?php if (get_post_meta($post->ID, 'producto-destacado', true) ) : ?>
     <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endif; ?>

elseそこにステートメントが必要ない限り、それはあなたのために仕事を成し遂げるはずです. あなたがするなら、少し違います。

于 2012-11-06T19:52:23.953 に答える