Skip to content

Instantly share code, notes, and snippets.

View cssgirl's full-sized avatar
:shipit:

Lindsey cssgirl

:shipit:
View GitHub Profile
@cssgirl
cssgirl / author.php
Created September 27, 2018 14:20
Get author info
<?php
/**
* The template for displaying Author Archive pages
*
* Methods for TimberHelper can be found in the /lib sub-directory
*
* @package WordPress
* @subpackage Timber
* @since Timber 0.1
*/
@cssgirl
cssgirl / author.php
Created September 27, 2018 14:20
Get author info
<?php
/**
* The template for displaying Author Archive pages
*
* Methods for TimberHelper can be found in the /lib sub-directory
*
* @package WordPress
* @subpackage Timber
* @since Timber 0.1
*/
@cssgirl
cssgirl / single.twig
Created September 27, 2018 14:27
Using WP Term Image and WP Term Colors w/ Timber
{# Adding color and image to single template #}
{# Where 'topics'/'topic' is your taxonomy #}
{% set topics = post.terms('topic') %}
{% if topics %}
<div class="taxonomy taxonomy--topic">
{% for term in topics %}
{# User term.meta to grab associated color/bg image #}
<div class="taxonomy__icon" style="background-color:{{ term.meta('color') }}; background-image:url({{ Image(term.meta('image')).src }});"></div>
@cssgirl
cssgirl / page-hero.twig
Created September 27, 2018 14:29
Page Hero
{% if is_home %}
{% set hero = post.get_field('hero') %} {# Grab custom field hero group #}
{% set background = hero.background_image %} {# Grab custom field bg image #}
{% else %}
{% set background = post.thumbnail.src('hero') %} {# Otherwise use featured image, with the 'hero' size #}
{% endif %}
{% embed "@components/page-hero/page-hero.twig" with
{
@cssgirl
cssgirl / hero.twig
Last active January 23, 2019 14:17
WordPress: Get a random row of hero data using ACF, groups, repeaters, and twig
{# Check if this is the front/homepage #}
{% if fn('is_front_page') %}
{# store our hero data #}
{% set image = hero_random_img.url %}
{% set title = hero_random_copy %}
{% set link = hero_random_link.url %}
{% set link_title = hero_random_link.title %}
{% set link_target = hero_random_link.target %}
{% set alignment = hero_random_alignment %}
// Move Yoast to bottom (why is it on top, really?)
function yoasttobottom() {
return 'low';
}
add_filter( 'wpseo_metabox_prio', 'yoasttobottom');
@cssgirl
cssgirl / vbguest.txt
Last active April 1, 2019 16:13
Vagrant vbguest install
// install vbguest so guest additions are updated when `vagrant up` is run (https://discoposse.com/2016/05/23/autoupdating-virtualbox-guest-additions-with-vagrant-vbguest/)
vagrant plugin install vagrant-vbguest
@cssgirl
cssgirl / wp-timber-twig-separate-parent-child-terms-taxonomies.twig
Last active August 25, 2020 19:02
WordPress Timber Twig - Separate parent/child taxonomies
{# Set variable containing parent and children terms. #}
{% set taxonomies %}
{# Set taxonomy to be queried #}
{% set taxonomy_name = 'taxonomy_name' %}
{# First gather only the parent terms. #}
{% set parents = post.terms( {query:{taxonomy: taxonomy_name, orderby:'name', order: 'ASC', parent:0}} ) %}
{# Show parents separated by comma #}
{{ parents|join(', ') }}
<br><br>