Skip to content

Instantly share code, notes, and snippets.

View simbasounds's full-sized avatar

Simon Barnett simbasounds

View GitHub Profile
@simbasounds
simbasounds / style.css
Last active November 9, 2017 19:49
Dynamic Image Scaling with Smartphone Landscape Exception
/*
* Dynamic Image Scaling with Smartphone Landscape Exception
* ----------------------------------------------------------
* Pic fits screen.
* Except on smartphone landscape,
* where it fills the width, and
* overflows the height.
*/
img.dynamic-size {
@simbasounds
simbasounds / Very Simple FlexBox override for WordPress Galleries.css
Last active September 18, 2016 18:05
This code will remove the borders around WordPress gallery images and change the layout model to CSS flexbox.
.gallery {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
}
@simbasounds
simbasounds / wp-template-for-bb.php
Created July 15, 2016 20:49
WordPress template < - > Beaver Builder layout template. Incl. hook for custom BB module.
<?php
add_action('fl_dynamic_switchboard', 'my_template_code');
function my_template_code() {
/* Your template loop code here */
}
add_action('fldts_fl_template','fldts_get_fl_template');
function fldts_get_fl_template() {
FLBuilder::render_query( array(
@simbasounds
simbasounds / structural-template-for-bbdts.php
Last active July 14, 2016 00:41
Sample WordPress structural template code for Dynamik Website Builder and Beaver Builder Dynamic Template Switchboard plugin.
<?php
add_filter( 'body_class', 'dynamik_page_builder_body_class' );
function dynamik_page_builder_body_class( $classes ) {
$classes[] = 'dynamik-page-builder';
return $classes;
}
add_action('fl_dynamic_switchboard', 'fldts_template_content');
function fldts_template_content() {
@simbasounds
simbasounds / Simple WordPress image gallery shortcode.php
Created January 10, 2016 19:06
Simple WordPress image gallery shortcode. Add to functions.php. Images categorised as 'Gallery' will be fetched. Data attribute is for Featherlight lightbox.
@simbasounds
simbasounds / single-cpt.php
Created January 10, 2016 15:53
Single Custom Post Type Template for WordPress or WordPress + Genesis.
<?php
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'custom_loop' );
function custom_loop() {
while ( have_posts() ) : the_post();
if ( has_post_thumbnail() ) {
$thumb_id = get_post_thumbnail_id();
$thumb_url = wp_get_attachment_image_src($thumb_id,'thumbnail', true);
$my_thumb_url = $thumb_url[0];
$my_post_thumb = "background-image: url(" . $my_thumb_url .");";
@simbasounds
simbasounds / Output content with html tags.php
Last active July 23, 2018 22:23
Output WordPress unstripped content (with html tags). Add to functions.php and use ob_wp_content() in templates instead of the_content()
//* Output Content with html tags
function ob_wp_content($display = true) {
global $post;
ob_start();
the_content();
$output = ob_get_contents();
ob_end_clean();
if(!$display) {return $output;} else {print $output;};
}
@simbasounds
simbasounds / Proportional size with vertical centring.css
Created January 10, 2016 15:24
Proportional size with vertical centring in CSS
/* Basic vertical centring (middle) */
.container {
position: relative;
}
.content {
position: absolute;
top: 50%;
-webkit-transform: translateY(-50%);
@simbasounds
simbasounds / register portolio cpt functions.php
Last active January 10, 2016 14:49
Code to be added to Genesis functions.php to have a portfolio custom post type with archive support
<?php
/* Do not remove this line. Add your functions below. */
// Register Portfolio Items Custom Post Type
function register_portfolio() {
$labels = array(
'name' => _x( 'Portfolio Items', 'Post Type General Name', 'text_domain' ),
'singular_name' => _x( 'Portfolio Item', 'Post Type Singular Name', 'text_domain' ),
'menu_name' => __( 'Portfolio Items', 'text_domain' ),
@simbasounds
simbasounds / Genesis archive-portfolio.php
Last active January 10, 2016 14:51
A portfolio custom post type archive with title, excerpt and thumbnail hooking into Genesis Framework
<?php
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
add_action( 'genesis_after_entry_content', 'add_entry_header' );
function add_entry_header() {