Skip to content

Instantly share code, notes, and snippets.

View misfist's full-sized avatar

Pea Lutz misfist

View GitHub Profile
@ChrisWebbNZ
ChrisWebbNZ / hierearchical-select-acf.php
Last active May 5, 2022 17:56
Hierarchical select for native Advanced Custom Fields taxonomy fields
/*
Got a hierarchical taxonomy in Wordpress? Want to make users select a top-level term first,
then one of its children, then maybe one of its children? Me too!
1. Create a native ACF taxonomy field, with multiple values allowed.
2. Add the following JS and PHP snippets to your theme / plugin - replace all instances of the field key with your own.
*/
@Garconis
Garconis / acf-states.txt
Created August 10, 2018 16:21 — forked from michaeldozark/acf-states.txt
State list for Advanced Custom Fields select field
AL : Alabama
AK : Alaska
AZ : Arizona
AR : Arkansas
CA : California
CO : Colorado
CT : Connecticut
DE : Delaware
DC : District of Columbia
FL : Florida
@misfist
misfist / direct_parent.php
Created October 22, 2017 22:01 — forked from levymetal/direct_parent.php
Custom Wordpress function which uses a nav walker to display a list of child pages from a common parent, which can be called from either the parent page (displays children) or any of the child pages (displays siblings). Detailed instructions available on my blog post here: http://christianvarga.com/how-to-get-submenu-items-from-a-wordpress-menu-…
<?php
wp_nav_menu( array(
'menu' => 'Menu Name',
'sub_menu' => true,
'direct_parent' => true
) );
@jaredatch
jaredatch / functions.php
Last active February 28, 2022 22:04
WordPress Search Autocomplete using WP REST API v2
<?php
/**
* Enqueue scripts and styles.
*
* @since 1.0.0
*/
function ja_global_enqueues() {
wp_enqueue_style(
'jquery-auto-complete',
/**
* Add the field "spaceship" to REST API responses for posts read and write
*/
add_action( 'rest_api_init', 'slug_register_spaceship' );
function slug_register_spaceship() {
register_rest_field( 'post',
'starship',
array(
'get_callback' => 'slug_get_spaceship',
'update_callback' => 'slug_update_spaceship',
function bidirectional_acf_update_value( $value, $post_id, $field ) {
// vars
$field_name = $field['name'];
$global_name = 'is_updating_' . $field_name;
// bail early if this filter was triggered from the update_field() function called within the loop below
// - this prevents an inifinte loop
if( !empty($GLOBALS[ $global_name ]) ) return $value;
@SamuelChristie
SamuelChristie / tls_1_deprecation.md
Created November 2, 2015 16:08
Explanation of how to detect TLS 1.0 connections and, by way of custom headers, warn the user about the coming change to more modern TLS versions.
@leepettijohn
leepettijohn / functions.php
Last active June 28, 2024 18:24
Add Event to The Events Calendar from a Gravity Form
//The following section is an add-on to this tutorial - https://tri.be/gravity-forms-events-calendar-submissions/
//Shout to CreativeSlice.com for their initial work
/* Before Starting:
- Make sure you have these three plugins installed
- Gravity Forms
- The Events Calendar
- Gravity Forms + Custom Post Types
- Once Gravity Forms is installed, create a form with these fields
- Single Line Text (Event Title)
- Paragraph Text (Event Description)
@wpchannel
wpchannel / mu-yoast-seo-disable-notifications.php
Last active April 16, 2023 08:33
Hide annoying notifications after each upgrade of Yoast SEO plugin and others admin notices
<?php if (!defined('ABSPATH')) die('Restricted Area');
/*
* Plugin Name: Disable Yoast SEO Notifications
* Description: Hide annoying notifications after each upgrade of Yoast SEO plugin and others admin notices.
* Version: 1.1
* Author: Aurélien Denis
* Author URI: https://wpchannel.com/
*/
@yoren
yoren / functions.php
Last active September 14, 2022 21:02
Add Featured Image Thumbnail URL to wp-json/wp/v2/posts Endpoint
<?php
function my_rest_prepare_post( $data, $post, $request ) {
$_data = $data->data;
$thumbnail_id = get_post_thumbnail_id( $post->ID );
$thumbnail = wp_get_attachment_image_src( $thumbnail_id );
$_data['featured_image_thumbnail_url'] = $thumbnail[0];
$data->data = $_data;