
Hi,
I’m not great at creating functions, especially for the repeater field.
I have a repeater field named “myPresto_player”
with 2 text sub_fields: “presto_time” and “presto_topic”
Here is code the Presto Player developer advised I used to display the videos timestamp & optional content:
$timestamp = get_field('timestamp_field');
$optional_text = get_field('optional_text_field');
echo do_shortcode ('[pptime time="' . esc_attr($timestamp) . '"]' . esc_html($optional_text) . '[/pptime]');
Here is the function I have written for a repeater field using the above code:
function display_presto_content() {
if( have_rows('my_presto_player') ):
while( have_rows('my_presto_player') ) : the_row();
$timestamp = get_sub_field('presto_time');
$optional_text = get_sub_field('presto_topic');
if (!empty($timestamp)) {
// Build the shortcode with the timestamp and optional text
$shortcode = '[pptime time="' . esc_attr($timestamp) . '"]' . esc_html($optional_text) . '[/pptime]';
echo do_shortcode($shortcode);
}
}
First off, I’m not sure I have written the function correctly. Also, I’m not sure how to display the fields in a post.
Would greatly appreciate help with this.
Continuing from your other post:
add_shortcode('showpptime', 'display_presto_content');
function display_presto_content($atts=array, $content='') {
$value = '';
if( have_rows('my_presto_player') ):
while( have_rows('my_presto_player') ) : the_row();
$timestamp = get_sub_field('presto_time');
$optional_text = get_sub_field('presto_topic');
if (!empty($timestamp)) {
// Build the shortcode with the timestamp and optional text
$shortcode = '[pptime time="' . esc_attr($timestamp) . '"]' . esc_html($optional_text) . '[/pptime]';
$value .= do_shortcode($shortcode);
}
return $value;
}