Skip to content

Instantly share code, notes, and snippets.

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

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 January 27, 2017 20:00
List WordPress pages using a template.
<?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 November 13, 2022 10:38
PHP Array isset and empty
@efuller
efuller / SassMeister-input-HTML.html
Created April 6, 2015 14:56
Generated by SassMeister.com.
<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 August 29, 2015 14:04
Add text fade effect to Genesis parallax theme.
<?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() ) {