Viewing 5 reply threads
  • Author
    Posts
    • #6113
      felix
      Member

      Hello,

      I created a custom post and i want to add a group of repeater (carousel) fields like:
      – imgage_url(upload an image),
      – image_external_link (link on image to external page),
      – image_caption (text description)
      I want to add several carousel elements and display it on custom post detail page.

      How may i achive this? Any code sample will be very helpfull. Thank you!

      PS: i take a look at “add_more” exemples but unfortunately i can not manage my problem.

    • #6119
      Steve
      Keymaster

      @felix– Welcome to the Piklist community!

      Actually, the add more field sounds perfect for what you want.

      Make sure you are using the latest beta. Then activate the Piklist demos. Add new Demo, click on the “Add More’s” tab and find the “Slide Images” field. I believe that’s what you want to use.

    • #6129
      felix
      Member

      Thank you so much, i almost succeed but i can’t display the images (the url and caption is displaying fine). May you give me some tips.

      Here is my piklist code:

      <?php
      /*
      Title: Carousel
      Post Type: post
      Order: 1
      Collapse: false
      Tab: Add-More's
      Sub Tab: Single Level
      Flow: Demo Workflow
      */
      
      piklist('field', array(
          'type' => 'group'
          ,'field' => 'slides_basic'
          ,'add_more' => true
          ,'label' => __('Slide Images with Basic uploader', 'piklist-demo')
          ,'description' => __('This is the same field as above, except it is using the Basic uploader.', 'piklist-demo')
          ,'fields'  => array(
            array(
              'type' => 'file'
              ,'field' => 'image'
              ,'label' => __('Slides', 'piklist-demo')
              ,'columns' => 12
              ,'validate' => array(
                array(
                  'type' => 'limit'
                  ,'options' => array(
                    'min' => 1
                    ,'max' => 1
                  )
                )
              )
            )
            ,array(
              'type' => 'text'
              ,'field' => 'url'
              ,'label' => __('URL', 'piklist-demo')
              ,'columns' => 12
            )
            ,array(
              'type' => 'text'
              ,'field' => 'caption'
              ,'label' => __('Caption', 'piklist-demo')
              ,'columns' => 12
            )
          )
        ));

      … and here is my display code:

      add_action('genesis_after_loop', 'qaz', 25);
      function qaz() {
          global $post;
              
              $carousel_builder = get_post_meta( get_the_ID(), 'slides_basic', true ); 
      
              foreach ( $carousel_builder as $carousel_build ) {
            
                  echo '<p>' . $carousel_build['image'] . '</p>';
                  
                  foreach ($m_event as $event) {
                     list($key, $value) = explode(',',$event);
                     $indexed_events[$key] = $value;
                  }
      
                  $carousel_buildimg = $carousel_build['image'];
                      foreach ($image_ids as $image) {
                              $myupload = get_post($image); 
                              $title = $myupload->post_title;
                              $description = $myupload->post_content;
                              $caption = $myupload->post_excerpt;
                              $res .= '<img img src="' . wp_get_attachment_url($image) . '" alt="'.$title.'">';        
                      }
                      
                  echo '<p>' . $carousel_build['url'] . '</p>';
                  echo '<p>' . $carousel_build['caption'] . '</p>';
              }
      }

      Thank you!

    • #6148
      Steve
      Keymaster

      you have an error in the image field. two img

      img img
      
    • #6150
      felix
      Member

      I corected the error …but the images don’t show up 🙁

    • #6156
      Steve
      Keymaster

      What happens if you just use:

      echo wp_get_attachment_url($image);
      
Viewing 5 reply threads
  • You must be logged in to reply to this topic.