This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//ADD RULE TO SECTION | |
add_filter('acf/location/rule_types', 'acf_location_rules_types'); | |
function acf_location_rules_types( $choices ) | |
{ | |
$choices['Other']['taxonomy_depth'] = 'Taxonomy Depth'; | |
return $choices; | |
} | |
//MATCHING OPERATORS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Field Group Location: Post Type Supports | |
* Plugin URI: http://qwp6t.me/acf-post-type-supports | |
* Description: Adds ACF Field Group location rule for Post Type Support. NOTE: You must first declare the supported feature in your theme. | |
* Version: 1.0.0 | |
* Author: QWp6t | |
* Author URI: http://qwp6t.me | |
* License: MIT License | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Created by PhpStorm. | |
* User: Matteo | |
* Date: 04/07/2018 | |
* Time: 12:52 | |
*/ | |
/** | |
* Class ACFToArray |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** Create Title and Slug */ | |
function acf_title( $value, $post_id, $field ) { | |
if ( get_post_type( $post_id ) === 'staff' ) { | |
$new_title = get_field( 'first_name', $post_id ) . ' ' . $value; | |
$new_slug = sanitize_title( $new_title ); | |
wp_update_post( | |
array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function acf_sync_field( $sync_field, $value, $post_id, $field ){ | |
// vars | |
$source_field = $field['name']; | |
$source_global_name = 'is_updating_' . $source_field; | |
$sync_global_name = 'is_updating_' . $sync_field; | |
// get this value early before anything is updated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ================================================================= | |
// ====== Custom admin + menus | |
// ================================================================= | |
/* Theme support for menus */ | |
add_theme_support( 'menus' ); | |
// Remove width and height attributes from images via WYSIWYG/admin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Set excerpt from ACF field | |
*/ | |
add_action('acf/save_post', function($post_id) { | |
$post_excerpt = get_field( 'short_description', $post_id ); | |
if ( ( !empty( $post_id ) ) AND ( $post_excerpt ) ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/////////////////////////////////// | |
/// SUPPORT FOR SEARCHING IN ACF | |
/////////////////////////////////// | |
/* Join posts and post-meta tables | |
* | |
* http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_join | |
*/ | |
function cf_search_join( $join ) { | |
global $wpdb; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//require( get_template_directory() . '/_/inc/_custom-post-types.php' ); | |
// Load jQuery | |
if ( !function_exists( 'core_mods' ) ) { | |
function core_mods() { | |
if ( !is_admin() ) { | |
wp_deregister_script( 'jquery' ); | |
wp_register_script( 'jquery', ( "//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ), false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$gallery = get_field('images'); | |
$rand = array_rand($gallery, 1); | |
if( $gallery ): ?> | |
<img src="<?php echo $gallery[$rand]['sizes']['large']; ?>" alt="<?php echo $gallery[$rand]['alt']; ?>" /> | |
<?php endif; ?> |