Home > Mobile >  Wordpress outputting same video url's
Wordpress outputting same video url's

Time:07-12

I'm trying to make a row layout where people can add an mp4 with ACF. So far so good, but when I try to add multiple video sections in the same post it outputs the same video in every player, even though they are different in the backend.

Does anyone know what I'm doing wrong?

Row layout:

<?php if (get_row_layout() == 'video') : ?>

    <?php get_template_part('template-parts/sections/section', 'video'); ?>

<?php endif; ?> 

Video section part

<div >

    <?php

    $video_mp4 =  get_field('video_file'); // MP4 Field Name
    $video_poster  = get_field('video_poster_image'); // Poster Image Field Name

    // Build the  Shortcode
    $attr =  array(
        'mp4'      => $video_mp4,
        'poster'   => $video_poster,
        'preload'  => 'auto'
    );


    echo wp_video_shortcode($attr);
     ?>

    
</div>

Many thanks in advance!

CodePudding user response:

now i have made a Flexible Content field called "video-section" and created a layout called "video-main' which contains a URL field called "video-url"

<?php if( have_rows('video-section') ): ?>
<?php while( have_rows('video-section') ): the_row(); ?>
    <?PHP 

   //get the URL 
    if( get_row_layout() == 'video-main' ): ?>
        <?php echo the_sub_field('video-url'); ?>

        <?php endif; ?>
        <?php endwhile; ?>
    <?php endif; ?>

I used this code to echo all different URLs that included in the post that I was created for testing try it if that what you want to do

CodePudding user response:

please check the ACF Documentation for get_row_layout() how to display it

Click here! to see it

  • Related