【问题标题】:wordpress custom tag get_post_meta(),how to retrieve several posts at a time?wordpress自定义标签get_post_meta(),如何一次检索多个帖子?
【发布时间】:2010-12-09 13:00:37
【问题描述】:

我正在尝试自定义一个 wordpress 插件,其中使用了自定义标签“get_post_meta()”。 代码如下:

<?php query_posts('showposts=5'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h2>" title="<?php the_title(); ?>">
<?php the_title(); ?></h2>
<?php the_excerpt(); ?>
<?php $gallery = get_post_meta($post->ID, 'Thumbnail', $single = true); ?>
<img src="<?php echo $gallery; ?>">`

我尝试将参数设为 false 并检索数组值,但它只返回一个值。 但它没有发生。还在 the_post() 之后尝试使用 foreach 循环。谁能建议我一次发几个帖子。实际上我想要不同的图片网址,这意味着几个 $gallery。

提前致谢。

【问题讨论】:

    标签: wordpress custom-tag


    【解决方案1】:

    试试这个:

    <?php while ( get_post_meta( $post->ID, 'Thumbnail', true ) != '' : ?>
    <img src="<?php get_post_meta( $post->ID, 'Thumbnail', true ); ?>" />
    <?php endwhile; ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多