duanliaoyu8419 2015-08-31 13:36
浏览 42

PHP显示一个ACF帖子,其中包含与其兄弟帖子不同的字段

I have 5 Galleries which are created using a Custom Post Type in Advanced Custom Fields. ONE of my galleries has a different set of fields from the other galleries. The reason for this is that I need to display an image and describe that image (and repeat for several images). I have used a Repeater field to do so for each image.

The code to display my other Galleries which simply feature the WYSIWYG and a Gallery field is as follows:

    if ( have_posts() ) while ( have_posts() ) : the_post(); 
      echo get_the_title();
      echo get_the_content(); 

      //Display images from Gallery Field
      $images = get_field('gallery_images');
          if( $images ): 
              foreach( $images as $image ): 
                  echo $image['url']; 
              endforeach; 
          endif;

How can I display the fields for my special gallery based on its individual post name or slug (which is Albums)

My repeater field is called album_information and it's sub fields are 'album_title', 'album_image' and 'album_description'.

Any help is much appreciated :)

  • 写回答

1条回答 默认 最新

  • doupi8598 2015-08-31 13:50
    关注

    http://www.advancedcustomfields.com/resources/repeater/#template-usage

    In your case:

    if( have_rows('album_information') ) {
        while ( have_rows('album_information') ) {
            the_row();
            the_sub_field('album_title');
            the_sub_field('album_image');
            the_sub_field('album_description');
        }
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度