Skip to content

Instantly share code, notes, and snippets.

View nickdavis's full-sized avatar

Nick Davis nickdavis

View GitHub Profile
@nickdavis
nickdavis / composer.json
Created July 29, 2022 10:22
composer.json starter
{
"name": "nickdavis/project-name",
"description": "",
"type": "project",
"license": "proprietary",
"prefer-stable": true,
"minimum-stability": "dev",
"repositories": [
{
"type": "composer",
<?php
add_filter( 'genesis_pre_get_option_content_archive_limit', __NAMESPACE__ . '\set_content_archive_limit', 11, 1 );
/**
* Forces the Genesis > Settings > Content Archives > Limit Content value to
* prevent an error with Events Calendar (v4.8.2) Archive pages in Genesis
* themes.
*/
function set_content_archive_limit() {
return 0;
@nickdavis
nickdavis / yoast-seo-carbon-fields.js
Created February 21, 2019 21:21
Adding Carbon Fields to Yoast SEO content analysis
/**
* Adds specified Carbon Field to the Yoast SEO content analysis.
*
* @link https://return-true.com/adding-content-to-yoast-seo-analysis-using-yoastseojs/
* @link https://kb.yoast.com/kb/can-i-add-data-to-the-page-analysis/
* @link https://github.com/Yoast/YoastSEO.js/blob/master/README.md
* @link https://github.com/Yoast/YoastSEO.js/issues/181#issuecomment-163162489
*/
(function($) {
@nickdavis
nickdavis / wp-config.php
Last active June 29, 2022 11:04
Additional settings for wp-config.php (public version)
<?php
/**
* Debug.
*/
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', false );
define( 'WP_DEBUG_LOG', true );
/**
@nickdavis
nickdavis / add-filter-shorcuts.php
Created March 16, 2018 21:40
add_filter shortcuts in WordPress
<?php
add_filter( 'my_filter', '__return_true' );
add_filter( 'my_filter', '__return_false' );
add_filter( 'my_filter', '__return_zero' );
add_filter( 'my_filter', '__return_null' );
add_filter( 'my_filter', '__return_empty_string' );
add_filter( 'my_filter', '__return_empty_array' );
@nickdavis
nickdavis / add-filter-remove-short-way.php
Last active March 16, 2018 21:37
A 'short way' example of removing text via add_filter in WordPress
<?php
/**
* Removes the text (short way).
*/
add_filter( 'my_filter', '__return_empty_string' );
@nickdavis
nickdavis / add-filter-remove-long-way.php
Last active March 16, 2018 21:36
A 'long way' example of removing text via add_filter in WordPress
<?php
add_filter( 'my_filter', 'remove_my_filter_text' );
/**
* Removes the text (long way).
*/
function remove_my_filter_text() {
return '';
}
@nickdavis
nickdavis / add-filter-modify.php
Last active March 16, 2018 21:34
An example of modifying text via add_filter in Wordpress
<?php
add_filter( 'my_filter', 'modify_my_filter_text' );
/**
* Modifies the text.
*/
function modify_my_filter_text() {
return 'Something else';
}
@nickdavis
nickdavis / functions.php
Created March 14, 2018 21:56
Get WordPress menu items data and render in a custom loop
<?php if ( has_nav_menu( 'how-can-we-help-you' ) ) :
$menu_slug = get_term( get_nav_menu_locations()['how-can-we-help-you'], 'nav_menu' )->slug;
$menu_items = wp_get_nav_menu_items( $menu_slug );
?>
<ul>
<?php foreach ( $menu_items as $menu_item ) : ?>
<li><a href="<?= $menu_item->url; ?>"><?= $menu_item->title; ?></li>
<?php endforeach; ?>
@nickdavis
nickdavis / functions.php
Last active March 14, 2018 21:47
Render a WordPress menu without the container
<?php
if ( has_nav_menu( 'footer-1' ) ) {
wp_nav_menu( array(
'theme_location' => 'footer-1',
'container' => '',
'menu_class' => 'footer_links', // You may want to add a particular CSS class to make it easier to identify
) );
}