Adding Multiple Videos

This feature is added to version: 2.8.9

We have a filter hook available for adding custom meta fields to the portfolio. And another action hook available to show any custom data in the quick view popup.

Here we are using these hooks for adding a repeater field for adding multiple videos adding fields and show them on the quick view.

Add this code on your theme or child theme functions.php file-

/**
 * Adding multiple videos meta
 */

add_filter( 'wpb_fp_metabox', 'wpb_fp_portfolio_multiple_videos_meta', 10, 2 );

if( !function_exists('wpb_fp_portfolio_multiple_videos_meta') ){

    function wpb_fp_portfolio_multiple_videos_meta( $fields, $prefix ){

        $fields[] = array(
            'label'     => esc_html__( 'Portfolio Videos', WPB_FP_TEXTDOMAIN ),
            'id'        => $prefix . 'videos',
            'type'      => 'repeatable',
            'sanitizer' => array(
                'video_item'  => 'no',
            ),
            'repeatable_fields' => array (
                'video_item' => array(
                    'label' => esc_html__( 'Video Iframe Code', WPB_FP_TEXTDOMAIN ),
                    'id'    => 'video_item',
                    'type'  => 'textarea'
                ),
            )
        );

        return $fields;
    }
}

/**
 * Showing multiple videos on popup
 */

add_action( 'wpb_fp_after_quick_view_img', function( $id ){
    
    $videos = get_post_meta( $id, 'wpb_fp_videos', true );

    if( is_array($videos) && !empty($videos) ){

        foreach ($videos as $video) {
            echo $video['video_item'];
        }
    }
} );
Was this article helpful to you? No Yes

How can we help?