Skip to content

Instantly share code, notes, and snippets.

@efuller
efuller / notes.md
Last active Mar 1, 2017 — forked from kellenmace/output-buffering-example.php
Template tags and Output Buffering at WDS
View notes.md

Information

This exploded into a big discussion about the creation of template tags and why you don’t have to always create a get and a do.

Example, in a loop you run do_my_thing(), the function do_my_thing() does not need to buffer the output if you’re just going to echo it out in the loop, so ob_start is not needed!

If, later, you find you need to get that string you can write a simple getter: https://gist.github.com/cd948f2b9f83625e09518c531d272d1c#file-output-buffering-example-php

Usually a template tag is wrote as a do first, and then a get later when it’s needed, but either way write your do and get when you need them, don’t build a get for the future unless it will be needed in the future

@efuller
efuller / functions.php
Created Jan 27, 2017
List WordPress pages using a template.
View functions.php
<?php
// source: https://paulund.co.uk/list-pages-using-page-template
$args = array(
'post_type' => 'page',
'meta_key' => '_wp_page_template',
'meta_value' => 'template-two-column-page.php', // the template you want to check
);
@efuller
efuller / array.md
Last active Mar 10, 2017
PHP Array isset and empty
View array.md
@efuller
efuller / SassMeister-input-HTML.html
Created Apr 6, 2015
Generated by SassMeister.com.
View SassMeister-input-HTML.html
<div class="container">
<ul>
<li>block 1</li>
<li>block 2</li>
<li>block 3</li>
<li>block 4</li>
<li>block 5</li>
<li>block 6</li>
<li>block 7</li>
<li>block 8</li>
@efuller
efuller / front-page.php
Last active Aug 29, 2015
Add text fade effect to Genesis parallax theme.
View front-page.php
<?php
add_action( 'wp_enqueue_scripts', 'parallax_enqueue_scripts' );
/**
* Enqueue Scripts
*/
function parallax_enqueue_scripts() {
if ( is_active_sidebar( 'home-section-1' ) ) {
if ( ! wp_is_mobile() ) {