Hi there
I have several custom post types with several custom fields. One of the fields is a text field which is used to generate shortcode to display an image slider (Using the RoyalSlider plugin)
This solution works fine however I’d like to find a way to return a list of available sliders instead of manually entering the shortcode. I’d like to return the slider titles. Is there a way to use ACF to achieve this?
At present I am doing this:
$shortcode = get_field('image_slider'); echo do_shortcode ($shortcode);
The Field ‘image_slider’ is a text field containing the shortcode e.g. [new_royalslider id=”1″].
RoyalSlider has a method which returns the Slider title:
global $wpdb; $prefix = $wpdb->prefix; $sliders = $wpdb->get_results("SELECT id,name FROM " . $prefix . "new_royalsliders ORDER BY id"); foreach ($sliders as $slider) { $name = $slider->name; $id = $slider->id; } echo $name;
}
But I don’t know how to use this with ACF to generate this as a post object for example or the gallery add on?
Any help would be awesome
Many thanks:
WP: 3.9
ACF: 4.3.8