Skip to content

Instantly share code, notes, and snippets.

@srikat
Last active February 8, 2017 00:40
Show Gist options
  • Select an option

  • Save srikat/9244167 to your computer and use it in GitHub Desktop.

Select an option

Save srikat/9244167 to your computer and use it in GitHub Desktop.
Equal height elements in WordPress using jQuery.equalHeights. http://sridharkatakam.com/equal-height-elements-wordpress-using-jquery-equalheights/
jQuery(document).ready(function($) {
$(window).load(function() {
if (window.innerWidth > 1024) {
$('.footer-widgets .widget-area').equalHeights();
}
});
$(window).resize(function(){
if (window.innerWidth > 1024) {
$('.footer-widgets .widget-area').height('auto');
$('.footer-widgets .widget-area').equalHeights();
}
});
});
//* Enqueue scripts
add_action( 'wp_enqueue_scripts', 'sk_enqueue_scripts' );
function sk_enqueue_scripts() {
wp_enqueue_script( 'equalheights', get_bloginfo( 'stylesheet_directory' ) . '/js/jquery.equalheights.min.js', array( 'jquery' ), '', true );
wp_enqueue_script( 'equalheights-init', get_stylesheet_directory_uri() . '/js/equalheights-init.js', array( 'equalheights' ), '1.0.0', true );
}
jQuery(document).ready(function($) {
$(window).load(function() {
if (window.innerWidth > 1024) {
$('.home .entry.teaser').equalHeights();
}
});
$(window).resize(function(){
if (window.innerWidth > 1024) {
$('.home .entry.teaser').height('auto');
$('.home .entry.teaser').equalHeights();
}
});
});
jQuery(document).ready(function($) {
$(window).load(function() {
if (window.innerWidth > 1024) {
$('.home .entry.teaser').equalHeights();
$('.home .entry.teaser').outerHeight("+=50");
}
});
$(window).resize(function(){
if (window.innerWidth > 1024) {
$('.home .entry.teaser').height('auto');
$('.home .entry.teaser').equalHeights();
}
});
});
//* Enqueue scripts
add_action( 'wp_enqueue_scripts', 'sk_enqueue_scripts' );
function sk_enqueue_scripts() {
if ( is_home() ) {
wp_enqueue_script( 'equalheights', get_bloginfo( 'stylesheet_directory' ) . '/js/jquery.equalheights.min.js', array( 'jquery' ), '', true );
wp_enqueue_script( 'equalheights-init', get_stylesheet_directory_uri() . '/js/equalheights-init.js', array( 'equalheights' ), '1.0.0', true );
}
}
@media only screen and (min-width: 1024px) {
.home .entry.teaser {
position: relative;
}
.home .entry.teaser .entry-footer .entry-meta {
padding-bottom: 32px;
position: absolute;
bottom: 0;
width: 100%;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment