Skip to content

Instantly share code, notes, and snippets.

View dgoze's full-sized avatar
💭
I may be slow to respond.

Daniel dgoze

💭
I may be slow to respond.
View GitHub Profile
@dgoze
dgoze / acf_gf_function.php
Created April 29, 2016 22:39 — forked from JodiWarren/acf_gf_function.php
Advanced Custom Fields (ACF) get_field helper function
/**
* Simple boolean helper to check if ACF is on.
* @return boolean
*/
function is_acf(){
return function_exists( 'get_field' ) ? true : false;
}
/**
* Helper function for ACF get_field function
@dgoze
dgoze / acf-settings.php
Created April 29, 2016 22:40 — forked from jdhobbsuk/acf-settings.php
ACF: Filter Post Object by posts owned by current author
function filter_acf_selection_by_ownership( $args, $field, $post ) {
$user = get_current_user_id();
if(get_current_user_role() != 'administrator' || get_current_user_role() != 'editor'):
$args['author'] = $user;
endif;
return $args;
@dgoze
dgoze / template.php
Created April 29, 2016 22:40 — forked from richgcook/template.php
Calculate number of days left on an event (WP/ACF)
<?php
$today = date('Ymd');
$today = strtotime($today);
$finish = get_field('end_date');
$finish = strtotime($finish);
$diff = $finish - $today;
$daysleft=floor($diff/(60*60*24));
@dgoze
dgoze / taxonomy.php
Last active September 12, 2019 23:12 — forked from yratof/taxonomy.php
List all taxonomies and loop their posts #post_type #taxonomy
<?php
/*
* Loop for taxonomies to show their posts
*/
$taxonomy = 'brand';
$terms = get_terms($taxonomy);
foreach ($terms as $term) {
$wpq = array (
@dgoze
dgoze / acf-list-value-from-subsites.php
Created April 30, 2016 04:53 — forked from webgurus/acf-list-value-from-subsites.php
Function to return an ACF field value for all the subsites on a network
<?php
function getAllCRMIds() {
global $wpdb;
$blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs} WHERE blog_id != {$wpdb->blogid} AND site_id = '{$wpdb->siteid}' AND spam = '0' AND deleted = '0' AND archived = '0' order by blog_id", ARRAY_A);
// array_unshift($blogs, 1); /*Including parent blog in the array*/
$crm_to_blog = array();
foreach($blogs as $blog) {
switch_to_blog( $blog[ 'blog_id' ] );
@dgoze
dgoze / acf_archive.php
Created April 30, 2016 04:57 — forked from mattradford/acf_archive.php
Retrieve ACF custom fields on an archive page
// http://www.advancedcustomfields.com/resources/how-to-get-values-from-a-taxonomy-term/
<?php
// vars
$queried_object = get_queried_object();
$taxonomy = $queried_object->taxonomy;
$term_id = $queried_object->term_id;
?>
<?php the_field('show_usp_strip', $queried_object); ?>
remove_action('wp_head', 'print_emoji_detection_script', 7);
remove_action('wp_print_styles', 'print_emoji_styles');
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
@dgoze
dgoze / unregister_widgets.php
Created April 30, 2016 05:05 — forked from mattradford/unregister_widgets.php
Unregister default and plugin widgets
function unregister_default_wp_widgets() {
unregister_widget('WP_Widget_Pages');
unregister_widget('WP_Widget_Calendar');
unregister_widget('WP_Widget_Archives');
unregister_widget('WP_Widget_Links');
unregister_widget('WP_Widget_Meta');
unregister_widget('WP_Widget_Categories');
unregister_widget('WP_Widget_Recent_Comments');
unregister_widget('WP_Widget_Tag_Cloud');
unregister_widget('WP_Widget_RSS');
@dgoze
dgoze / acf_post_parent_field.php
Created April 30, 2016 05:05 — forked from mattradford/acf_post_parent_field.php
ACF get field from post parent
<?php $parent_id = $post->post_parent; ?>
<?php the_field('custom_field', $parent_id); ?>
@dgoze
dgoze / acf_slider_bootstrap
Created April 30, 2016 05:06 — forked from webgurus/acf_slider_bootstrap
Root's bootstrap slider example with Advanced Custom Fields Gallery plugin.
<?php
/* SLIDER CUSTOM FIELD FOR HOMEPAGE */
$images = get_field('slider_photos');
$count=0;
$count1=0;
if($images) : ?>
<div id="slider">
<div id="carousel" class="carousel slide">
<!-- Indicators -->