CodeHQ

Archive for February, 2016

|

Object-fit fallback | CSS

Wednesday, February 24th, 2016

Object fit details here

Tags: , , , ,
Posted in CSS | No Comments »

ACF – Flexible content | WordPress

Wednesday, February 24th, 2016

Useful code for Advanced custom fields (ACF) flexible content – perfect for page builders

<?php
if( have_rows('pagebuilder') ):
    while ( have_rows('pagebuilder') ) : the_row();
        if( get_row_layout() == 'hero' ):
        	
        	get_template_part( 'assets/parts/pagebuilder/hero');
     
		elseif( get_row_layout() == 'call_to_action' ):
		
        	get_template_part( 'assets/parts/pagebuilder/call-to-action');
 
        endif;
    endwhile;
else :
    // no layouts found
endif;
?>

Tags: , , , ,
Posted in PHP, WordPress | No Comments »

WordPress OEmbed – responsive video

Thursday, February 18th, 2016

Adds a container around iframes to allow responsive video when utilising WordPress OEmbed functionality.

jQuery

$("iframe").wrap("<div class='iframe-container'/>");

SCSS

.iframe-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    iframe {
        position: absolute;
        top:0;
        left: 0;
        width: 100%;
        height: 100%;
    }
}

Original source

Tags: , , , , ,
Posted in CSS, WordPress | No Comments »