Skip to content

Instantly share code, notes, and snippets.

View craigsimps's full-sized avatar

Craig Simpson craigsimps

View GitHub Profile
@craigsimps
craigsimps / functions.php
Last active June 14, 2017 15:45
Add the day of the week to the body classes.
<?php
// Add the day of the week to the body classes.
add_filter( 'body_class', 'add_day_of_the_week_to_class_names' );
function add_day_of_the_week_to_class_names( $classes ) {
$classes[] = strtolower( date( 'l' ) );
return $classes;
}
@craigsimps
craigsimps / style.css
Created August 25, 2015 20:56
Example of using the day of the week in a body class, and how we can use it.
.monday .entry-title {
color: red;
}
.tuesday .entry-title {
color: blue;
}
.wednesday .entry-title {
color: green;
@craigsimps
craigsimps / functions.php
Created September 14, 2015 08:19
Remove links from post titles in Genesis.
<?php
add_filter( 'genesis_post_title_output', 'genesis_starter_custom_post_title' );
/**
*
* Remove Links from Post Titles in Genesis
*
* @author Joshua Nelson
* @link http://joshuadnelson.com
*
@craigsimps
craigsimps / functions.php
Created December 14, 2015 14:39
Simple function to determine if a date is in the future.
/**
*
* Simple function to determine if a date is in the future.
*
* @param $time
*
* @return bool
*/
function isFuture($time)
{
@craigsimps
craigsimps / functions.php
Last active April 8, 2022 04:34
Example of multiple uses of genesis_register_sidebar.
<?php
//* Register widget areas
genesis_register_sidebar( array(
'id' => 'home-section-1',
'name' => __( 'Home Section 1', 'parallax' ),
'description' => __( 'This is the home section 1 section.', 'parallax' ),
) );
genesis_register_sidebar( array(
'id' => 'home-section-2',
@craigsimps
craigsimps / sidebars.php
Last active December 23, 2015 18:26
Refactor code to register multiple widget area from Parallax Pro theme.
<?php
/**
* Register sidebars.
*
* @author Craig Simpson <craig@designed2.co.uk>
* @package Genesis_Starter_Theme
* @since 1.0.0 Initial Commit
*/
$sidebars = [
@craigsimps
craigsimps / styleguide.html
Created December 30, 2015 22:38
Basic HTML elements for copy & paste into WordPress page.
<h1>Basic Elements</h1>
<p>Lorem ipsum dolor sit amet, <a href="#" title="test link">test link</a> adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus. Maecenas ornare tortor. Donec sed tellus eget sapien fringilla nonummy. Mauris a ante. Suspendisse quam sem, consequat at, commodo vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus.</p>
<p>Lorem ipsum dolor sit amet, <em>emphasis</em> consectetuer adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus. Maecenas ornare tortor. Donec sed tellus eget sapien
@craigsimps
craigsimps / header.php
Created January 6, 2016 09:50
Returning multiple ACF fields dynamically.
$post_id = get_the_ID();
$fields = [
'front_page_image_title',
'front_page_introduction',
];
foreach ( $fields as $field ) {
${$field} = get_post_meta( $post_id, $field, true);
}
@craigsimps
craigsimps / snippets.php
Created January 8, 2016 23:37
Example adding a meta box to CPT Archive Settings page, saving and loading values.
<?php
add_filter( 'genesis-cpt-archive-snippet', 'cs_add_additional_field' );
/**
* Add additional field to the Genesis CPT Archive Settings array for snippet post type.
*
* @param array $default_settings
* @return array modified default_settings
*
*/
@craigsimps
craigsimps / Meta.php
Created January 18, 2016 21:31
Class which will retrieve custom fields when passed an array of field names.
<?php
/**
* Simple class designed to return
* multiple custom fields.
*
* This is a simple class which will
* return custom fields in the format
* $this->field_name when passed an
* array of custom field names.
*