Skip Navigation

[Resolved] I want to create slider from 1 post.

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to create a slider. Each slide should be an image from a repeating custom field in a single post, along with its caption as stored in the Media Library.

Solution:
This isn't possible using a standard Views slider. This approach requires custom code. Follow the steps outlined in this post:
https://toolset.com/forums/topic/create-a-slider-with-multiple-images-from-image-fields/

To display the image caption, add this custom shortcode function to functions.php:

add_shortcode( 'toolset_get_image_caption', 'toolset_get_image_caption_func');
function toolset_get_image_caption_func($atts)
{
  global $wpdb;
  $url = $atts['url'];
  $id = $wpdb->get_var( $wpdb->prepare ("SELECT ID FROM $wpdb->posts WHERE guid=%s ORDER BY `ID` DESC", $url ) );
  $excerpt = get_the_excerpt($id);
  if($excerpt)
    return $excerpt;
  $attachment_meta = get_post_meta( $id, '_wp_attachment_metadata', true );
  if (isset($attachment_meta['image_meta']))
    return $attachment_meta['image_meta']['caption'];
}

Then use the shortcode like so:

[toolset_get_image_caption url="[types field='gallery' url='true']"]
This support ticket is created 6 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 15 replies, has 2 voices.

Last updated by Junichiro Taira 6 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#521843

Dear Christian

Thank you so much for your great support !!!
Finally I could make what I want to.
This type of slider and setting was I always wanted to do for 3 years.
I'm very happy to buy toolset !!!

Thank you again

June

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.