Skip to content

Instantly share code, notes, and snippets.

View simbasounds's full-sized avatar

Simon Barnett simbasounds

View GitHub Profile
@simbasounds
simbasounds / 0_reuse_code.js
Created April 8, 2014 21:32
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
<?php
add_action('genesis_after_header','portfolio_title');
function portfolio_title() { ?>
<div class="portfolio-title">
<div class="wrap">
<h1 class="entry-title" itemprop="headline">
<span class="portfolio-headline">Portfolio » </span>
<?php the_title(); ?>
</h1>
@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() {
@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 / 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 / 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 / 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 / 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 / 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 / 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(