Tagged: add carousel to custom post type
- This topic has 5 replies, 2 voices, and was last updated 5 years, 10 months ago by
Steve.
-
AuthorPosts
-
-
March 18, 2016 at 1:38 am #6113
felixMemberHello,
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.
-
March 18, 2016 at 2:09 pm #6119
SteveKeymaster@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.
-
March 21, 2016 at 6:10 am #6129
felixMemberThank 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!
-
March 22, 2016 at 11:12 pm #6148
SteveKeymasteryou have an error in the image field. two
imgimg img
-
March 23, 2016 at 3:23 am #6150
felixMemberI corected the error …but the images don’t show up 🙁
-
March 23, 2016 at 10:21 am #6156
SteveKeymasterWhat happens if you just use:
echo wp_get_attachment_url($image);
-
-
AuthorPosts
- You must be logged in to reply to this topic.