black friday sale

Custom Fields
Re-Envisioned
Support Meta Box Group How to the video field for group type?

  • Creator
    Topic
  • #8793
    Resolved alisha
    Participant

    Hello,
    How are you doing?Hope doing well.Now let you know my problem.
    Simply, I cannot display video field using group type.
    I am using following code to create meta box:
    https://pastebin.com/G2wbrww4
    I am using following codes to show the video but no result:
    https://pastebin.com/AnzedNNE
    It shows following error:
    Warning: Illegal string offset ‘src’ in C:\wamp\www\wordpress\wp-content\themes\skeleton\framework\about-us\facility.php on line 41
    please help me.
    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #8805
    Anh Tran
    Keymaster

    Hi,

    Thanks. I’m good 🙂

    Regarding the video field, when getting from the group, it’s just the IDs of the uploaded videos. To output the videos, you can do like this:

    <?php
    foreach ( $facilities_videos as $facilities_video ) {
        $facilities_video = RWMB_Video_Field::file_info( $facilities_video );
        ?>
        <video src="<?php echo $facilities_video['src']; ?>">
    <?php } ?>
    #18683
    DanielMamet
    Participant

    Hello,

    I want to output a video player with playlist but how to do that using Meta Box Builder and MB Views, in detail the video custom field within a group field?

    What are the steps or what is the twig code to achieve that? Can you please give a complete example. Thank you!

    #18692
    Anh Tran
    Keymaster

    Hi Daniel,

    Currently, MB Views allows you to display videos one by one, e.g. not in a playlist. To do that, please select the video field from the inserter panel.

    To display all videos in a playlist, please use this Twig snippet below:

    {% set videos = mb.rwmb_meta( 'video_field_id', '', post.ID ) %}
    {% set video_ids = mb.implode( ',', mb.wp_list_pluck( videos, 'ID' ) ) %}
    {{ mb.wp_playlist_shortcode( {ids: video_ids, type: 'video'} ) }}
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.