• Hello!
    I’m new on PHP and I’m trying to embed a youtube video on WordPress. I created an Advanced Custom Field where the user can simply put the name of the video and paste the url. With the code below it seems to work well but…

    <?php $loop = new WP_Query( array( ‘post_type’ => ‘course_video’,
    ‘orderby’ => ‘post_id’, ‘order’ => ‘ASC’ ) ); ?>

    <?php while( $loop->have_posts() ) : $loop->the_post(); ?>

    <h2><?php the_title(); ?></h2>

    <?php echo wp_oembed_get( get_field( ‘video_url’ ) ) ?>

    <?php endwhile; wp_reset_query(); ?>

    I’d like to see the video wider and then I tried this similar code:

    <?php $loop = new WP_Query( array( ‘post_type’ => ‘course_video’,
    ‘orderby’ => ‘post_id’, ‘order’ => ‘ASC’ ) ); ?>

    <?php while( $loop->have_posts() ) : $loop->the_post(); ?>

    <h2><?php the_title(); ?></h2>

    <iframe width=”100%” height=”415″
    src=”<?php echo wp_oembed_get( get_field( ‘video_url’ ) ) ?>”
    frameborder=”0″ allowfullscreen></iframe>

    <?php endwhile; wp_reset_query(); ?>

    And I get this error:

    Forbidden

    You don’t have permission to access /b2w/

    Apache/2.4.9 (Win64) PHP/5.5.12 Server at localhost Port 80

    There’s any way to resize the video using my first code? And what I’m doing wrong in the second code?

    I’m stuck with this, I searched a lot and I didn’t find the reason neither a different approach to get this working well.

    Thanks in advance

The topic ‘Using wp_oembed_get within Iframe getting Forbidden error’ is closed to new replies.