Support

Account

Home Forums Front-end Issues Issue with Displaying Custom Shortcode Reply To: Issue with Displaying Custom Shortcode

  • Your shortcode is just running shortcodes and not producing anything.

    First your loop should be inside of your shortcode function.

    Second you need to return the html

    this is just a guess, but hopefully you get the idea.

    
    function display_presto_content($content) {
    ob_start();
    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)) {
                $shortcode_content = '[pptime time="' . esc_attr($timestamp) . '"]' . esc_html($optional_text) . '[/pptime]';
                display_presto_content($shortcode_content);
            }
        endwhile;
    
      return ob_get_clean();
    }
    
    add_shortcode('showpptime', 'display_presto_content');