Skip to content

Instantly share code, notes, and snippets.

View dannydickson's full-sized avatar

Danny D. dannydickson

View GitHub Profile
@dannydickson
dannydickson / hide-gravity-forms-labels.php
Created June 29, 2019 10:52
Enable: Hide Gravity Forms Labels
// Place in functions.php
// Enables option to hide Gravity Forms labels in WP backend the right way instead of display: none CSS
add_filter( 'gform_enable_field_label_visibility_settings', '__return_true' );
@dannydickson
dannydickson / hide-gravity-forms-labels.php
Created June 29, 2019 10:52
Enable: Hide Gravity Forms Labels
// Place in functions.php
// Enables option to hide Gravity Forms labels in WP backend the right way instead of display: none CSS
add_filter( 'gform_enable_field_label_visibility_settings', '__return_true' );
@dannydickson
dannydickson / material-icons-list-for-dropdown.txt
Created July 11, 2019 23:18
Material Icons List for Dropdown
3d_rotation
ac_unit
access_alarm
access_alarms
access_time
accessibility
accessible
account_balance
account_balance_wallet
account_box
@dannydickson
dannydickson / sort-by-custom-field.php
Last active July 11, 2019 23:32
Sort by custom field in WordPress
<?php
// Taken and modified from https://www.advancedcustomfields.com/resources/orde-posts-by-custom-fields/
// Put here for posterity's sake as a bookmark of sorts
// Allows sorting by custom field value instead of default.
// This will allow client to be able to set the order of these goals/landing pages as they add more.
// Can be added to functions.php, or to custom template that gets called before your custom loop.
function my_pre_get_posts( $query ) {
// do not modify queries in the admin
@dannydickson
dannydickson / dark-theme.css
Last active August 20, 2019 20:03
My Slack Dark Theme CSS File
.p-unreads_view__header {
background: #545454 !important;
color: #222 !important;
}
::-moz-placeholder {
color: #e6e6e6 !important;
filter: none;
opacity: 0.5;
}
@dannydickson
dannydickson / dynamic-classes-wp-menu-items.php
Created October 19, 2019 00:01
Add dynamic ACF classes to WordPress menu items (used for dynamically changing colors based on ACF field. Utilizes Tailwind CSS utility classes)
/**
* Adds custom classes to WP Menu Items in Primary theme menu (header)
*/
function header_menu_classes( $classes, $item, $args ) {
// Store primary color and saturation from ACF as variable
$primary_color = get_field('primary_color', 'option');
$primary_color_saturation = get_field('primary_color_saturation', 'option');
// If menu-1 aka primary theme menu filter the classes for WP menu-items
if ( 'menu-1' === $args->theme_location ) {
// adds custom classes including dynamic primary color
@dannydickson
dannydickson / add-link-to-wp-admin-bar.php
Last active February 11, 2020 18:46
Add custom link to WP admin bar
@dannydickson
dannydickson / acf-flexible-or-standard-content.php
Created April 29, 2021 23:08
If we have ACF flexible content rows setup on the page, display those. Otherwise, display the standard content.
<?php
// If have flexible content rows
if (have_rows('layouts')) :
while (have_rows('layouts')) : the_row();
$class = 'container';
if (get_sub_field('background_color')) {
$class .= ' ' . get_sub_field('background_color');
}
@dannydickson
dannydickson / parks-greenways-blog-loop-for-sidebar.php
Last active April 29, 2021 23:09
CCPR - Parks and Greenways Single Post Loop for Sidebar
<?php
/*
* The WordPress Query class.
*
* @link http://codex.wordpress.org/Function_Reference/WP_Query
*/
$args = array(
'p' => get_field('blog_post'),
'posts_per_page' => 1,
);
@dannydickson
dannydickson / back-to-top.js
Last active June 7, 2021 23:14
Floating Font Awesome Back to Top Button in WordPress
$(".to-top-btn").click( function(){
$("html, body").animate({ scrollTop: 0 }, "slow");
});