Skip Navigation

[Résolu] Flexslider captions for single image field.

This support ticket is created Il y a 7 années et 2 mois. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Marqué : 

Ce sujet contient 2 réponses, a 2 voix.

Dernière mise à jour par Akhil Il y a 7 années et 2 mois.

Assisté par: Luo Yang.

Auteur
Publications
#572155

Hi, Luo.

I have few images custom field. named
property-photo , property-image1,...property-image6.

I manage to get the slider running here:
lien caché
[the slider script is at the js script tab.]

you can see here:
lien caché

The title is working fine but it's not displaying as a caption.

Pls, look into this pls.
I wanted to have final result like this: lien caché

i believe you have my login details from the prev topics. thanks.

#572374

Dear C6410,

Please check the document of flexslider:
lien caché
click tab "HTML", you will see their HTML codes, for example:

...
    <li>
      <img src="slide1.jpg" />
      <p class="flex-caption">Adventurer Cheesecake Brownie</p>
    </li>
...

It needs to output the caption text outside the HTML img tag

But there Types image shortcode:
https://toolset.com/documentation/customizing-sites-using-php/functions/#image
It can not output the image title or caption independently. so there isn't such a feature within Types plugin or Views plugin, I suggest you try to create a custom shortcode for it, for example:
1) use below PHP codes to create a custom shortcode [image_title]
lien caché

add_shortcode('image_title', 'my_images_shortcode');
function my_images_shortcode($atts,$content) {
	global $wpdb;

	$atts = shortcode_atts( array(
			  'field' => '',
	), $atts );
	$image = get_post_meta(get_the_ID(), 'wpcf-' . $atts['field'], true);
	
	$attachment_id = $wpdb->get_var($wpdb->prepare(
		"SELECT ID FROM $wpdb->posts WHERE guid = %s",
		$image
	));
	$image_title = get_the_title($attachment_id);
	return $image_title;
}

2) Put it into the content like this:
lien caché

    <li>
      <img src="[types field="property-photo" size="medium" url="true" resize="proportional"][/types]" /> 
       <p class="flex-caption">[image_title field='property-photo']</p>
    </li>
#572410

Perfect job , thank you.