Embed video on a post and display it on a single post and a page.

Reusable Custom Blocks
  • Create an ACF with the field type Gallery.
  • You can select a location on what post type you are going to display in the custom field.



Display on a Single Post

  • Add a lazy block with the name “Embed Video” with no content controls and inspector controls. And use a theme template for the output method, then create a file under  “/wp-content/themes/blockbase-child/blocks/lazyblock-embed-video/block.php”.
  • Note: You can use whatever type of output method you would like to use.
  • Add this code and save.
<?php
/*
    Video Embed
*/
?>
<div class="embed-container">
    <?php the_field('video'); ?>
</div>
  • Display the custom field to a specific single post by using the custom block you created (Embed Video block).

Display on a Page

  • Add a lazy block with the name “Custom Post Video” with no content controls and inspector controls. And use a theme template for the output method, then create a file under “/wp-content/themes/blockbase-child/blocks/lazyblock-custom-post-video/block.php”.
  • Note: You can use whatever type of output method you like to use.
  • Add this custom code and save. Note: You can change it according to your style and needs.
<?php
/**
** Custom Post Video
**/

?>
<style>
.wp-block-lazyblock-custom-post-video{
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    position:relative;
}	
.team_all_box{
    background: #F5F5FF;
    border-radius:5px;
}

/* PAGINATION */
.pagination{
    position:absolute;
    bottom:-3em;
    text-align:center;
    width:100%;
}
.pagination a,
.pagination .current{
    border-radius: 5px;
    padding: 5px 1em;
    text-decoration:none;
}
.pagination .current{
    background-color:#FF7900;
}
	
</style>
<?php 
   $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
   $loopb = new WP_Query( array( 'post_type' => 'post', 'posts_per_page' => 3, 'paged' => $paged, 'order' => 'DESC' ) );
   $ctr = 0;
   if( $loopb->have_posts() ) ;
   while ( $loopb->have_posts() ) : $loopb->the_post(); 
   $post_ID = get_the_id();
   $content = get_the_content(); 
   $thumb_image_arr = wp_get_attachment_image_src(get_post_thumbnail_id(),'full');
   $thumb_image = $thumb_image_arr[0];
?>
	<div class="team_all_box">
		<div class="embed-container">
			<?php the_field('video'); ?>
		</div>
		<div class="team-content">
			<h2><?php the_title(); ?></h2>
		</div>

	</div>

<?php endwhile; ?>
<div class="pagination">
<?php

 $total_pages = $loopb->max_num_pages;
 
    if ($total_pages > 1){
        $current_page = max(1, get_query_var('paged'));
 
        echo paginate_links(array(
            'base' => get_pagenum_link(1) . '%_%',
            'format' => '/page/%#%',
            'current' => $current_page,
            'total' => $total_pages,
        ));
    }
	
 ?>
</div>
<?php wp_reset_postdata(); ?>
  • Display the block to a specific single page by using the custom block you created (Embed Video block).

Leave a Reply

Your email address will not be published. Required fields are marked *