Skip to content

Instantly share code, notes, and snippets.

@cdils
cdils / functions.php
Last active February 6, 2024 09:51
Add utility bar widget areas above header.
<?php // Remove this line
/** Register Utility Bar Widget Areas. */
genesis_register_sidebar( array(
'id' => 'utility-bar-left',
'name' => __( 'Utility Bar Left', 'theme-prefix' ),
'description' => __( 'This is the left utility bar above the header.', 'theme-prefix' ),
) );
genesis_register_sidebar( array(
<?php
/** Template for displaying single posts.
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post
*/
// Theme template stuff
// Blah blah
the_loop()
<?php
/**
* Get a reusable block by its title.
*
* @param string $title The post title of the reusable block.
* @param bool $filter_results Whether the results should be filtered through the_content filter.
* @return string|null The reusable block content if found, null otherwise.
*/
function get_reusable_block( $title, $filter_results = true ) {
@cdils
cdils / archive-testimonials.php
Last active April 17, 2023 20:13
This is code for a custom page template removing the standard Genesis loop and inserting a custom loop. Similar to https://gist.github.com/4684423.js, but without a grid loop.
<?php
/**
* Template Name: Testimonial Archives
* Description: Used as a page template to show page contents, followed by a loop through a CPT archive
*/
remove_action ('genesis_loop', 'genesis_do_loop'); // Remove the standard loop
add_action( 'genesis_loop', 'custom_do_loop' ); // Add custom loop
@cdils
cdils / simple-social-icons.php
Created May 1, 2014 20:44
Pre-load styles for simple social icons
// Default Simple Social Icon Styles
add_filter( 'simple_social_default_styles', 'minmimum_default_style' );
function minmimum_default_style( $defaults ) {
$defaults['size'] = '100';
$defaults['border_radius'] = '100';
$defaults['icon_color'] = '#fff';
$defaults['icon_color_hover'] = '#fff';
$defaults['background_color'] = '#404435';
$defaults['background_color_hover'] = '#3c4556';
@cdils
cdils / wpmdbpro-cli-remote-backup-script.sh
Last active October 25, 2022 19:21 — forked from JRGould/wpmdbpro-cli-remote-backup-script.sh
WP Migrate DB Pro CLI Backup Script
#!/bin/bash
#
# Declare SITES as an associative array
declare -A SITES
# Format: SITES[WPMDB profile number]=backup_filename_base
SITES[1]=remote_backup_com
#SITES[2]=another_site_to_backup
#SITES[3]=my_other_blog
## These variables will be specific to the WordPress
@cdils
cdils / functions-step1.php
Last active October 25, 2022 17:09
Here's a tutorial for the following snippets showing you how to customize Yoast Breadcrumbs https://carriedils.com/modify-yoast-breadcrumb-text-for-parent-and-child-pages/
<?php
/**
* Filter breadcrumbs on Salary Data pages.
*
* @param array $link The link array.
* @param array $breadcrumb The breadcrumb item array.
*
* @return str $link The link output.
*/
function zg_add_text_to_breadcrumb( $link, $breadcrumb ) {
@cdils
cdils / gutenberg-style.css
Created May 9, 2018 13:48
This is an unminified version of the stylesheet that ships with the WordPress Gutenberg plugin. Original SCSS files are here -> https://github.com/WordPress/gutenberg/tree/master/core-blocks
.wp-block-embed figcaption {
margin-top: .5em;
color: #6c7781;
text-align: center;
font-size: 13px
}
.editor-block-list__block[data-type="core/embed"][data-align=left] .editor-block-list__block-edit,
.editor-block-list__block[data-type="core/embed"][data-align=right] .editor-block-list__block-edit,
.wp-block-embed.alignleft,
@cdils
cdils / comment-notes-before.php
Last active March 4, 2022 22:37
Customize the text before the comment form in WordPress. Note: Logged in users will not see this text.
<?php //remove this line
add_filter( 'comment_form_defaults', 'cd_pre_comment_text' );
/**
* Change the text output that appears before the comment form
* Note: Logged in user will not see this text.
*
* @author Carrie Dils <http://www.carriedils.com>
* @uses comment_notes_before <http://codex.wordpress.org/Function_Reference/comment_form>
*
@cdils
cdils / change-style-load-order.php
Last active February 7, 2022 15:35
Change order of where Genesis child theme stylesheet is loaded on theme initialization.
<?php //Remove this line
/**
* Remove Genesis child theme style sheet
* @uses genesis_meta <genesis/lib/css/load-styles.php>
*/
remove_action( 'genesis_meta', 'genesis_load_stylesheet' );
/**
* Enqueue Genesis child theme style sheet at higher priority