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
<?php
/**
* WordPress API for creating bbcode like tags or what WordPress calls
* "shortcodes." The tag and attribute parsing or regular expression code is
* based on the Textpattern tag parser.
*
* A few examples are below:
*
* [shortcode /]
* [shortcode foo="bar" baz="bing" /]
@dgoze
dgoze / README.md
Created July 24, 2024 18:02 — forked from theJasonJones/README.md
Auto Populate Wordpress ACF Repeater values

Add default values to ACF Repeater Fields

I came across this solution when I had about a ton of posts (200+) with values in various PDFs. I didn't want to have to spend time filling out the same values over and over again.

Walkthrough

This case is pretty straight forward; I have one repeater field field_123a56b7cb890 that has a text fields inside it (field_588a24c3cb782). I haven't tried any other types like post objects or radio buttons, but I'm sure it can be done.

Step 1. Hook into acf/load_value on your repeater field. You can use type/key/name as desired here.

@dgoze
dgoze / ACF_Layout.php
Created July 24, 2024 18:01 — forked from beaucharman/ACF_Layout.php
Logical layout automation for Advanced Custom Fields and it's Flexible Content Field add on. http://www.advancedcustomfields.com/ http://www.advancedcustomfields.com/add-ons/flexible-content-field/
<?php
/**
* ACF Layout
* @version 1.0 | November 12th 2013
* @author Beau Charman | http://twitter.com/beaucharman
* @link https://gist.github.com/beaucharman/7181406
* @license MIT license
*
* Logical layout automation for Advanced Custom Fields and it's Flexible Content Field add on.
@dgoze
dgoze / functions.php
Last active July 24, 2024 18:01 — forked from lukecav/functions.php
Expire posts to draft using a datepicker field in ACF
// Expire events
if ($expireTransient = get_transient($post->ID) === false) {
set_transient($post->ID, 'set for 1 minutes', 1 * MINUTE_IN_SECONDS );
$today = date('Y-m-d H:i:s', current_time('timestamp', 0));
$args = array(
'post_type' => 'events',
'posts_per_page' => 200,
'post_status' => 'publish',
'meta_query' => array(
array(
@dgoze
dgoze / wp-image-filters.php
Created July 24, 2024 18:01 — forked from davidsword/wp-image-filters.php
WordPress - All filters to modify an images URL (as far as I could find)
<?php
// Images in post galleries
add_filter( 'get_post_galleries', '_img_url_filter', PHP_INT_MAX );
add_filter( 'widget_media_image_instance', '_img_url_filter', PHP_INT_MAX );
// Core image retrieval
add_filter( 'image_downsize', '_img_url_filter', 10, 3 );
// Responsive image srcset substitution
<?php
/**
* Save Gravity Forms event registration file to media library.
*/
class WDSP_Event_Form {
/**
* Instance of class.
*
* @var class
@dgoze
dgoze / acf_image_to_featured_image.php
Created July 24, 2024 18:00 — forked from morgyface/acf_image_to_featured_image.php
WordPress | Set ACF image to be the WP feature image
@dgoze
dgoze / acf_custom_search.php
Created July 24, 2024 18:00 — forked from wking-io/acf_custom_search.php
How to search a specific custom post type and the ACF fields within
<?php
/**
* [list_searcheable_acf list all the custom fields we want to include in our search query]
* This could easily be something that is added to the admin as a plugin so that users can
* add searchable fields in an options table
* @return [array] [list of custom fields]
*/
function list_searcheable_acf(){
$list_searcheable_acf = array("title", "sub_title", "excerpt_short", "excerpt_long", "xyz", "myACF");
return $list_searcheable_acf;
@dgoze
dgoze / acf-functions-helper.php
Created July 24, 2024 17:59 — forked from herewithme/acf-functions-helper.php
ACF template helper - Checks if at least one field is completed by BO for display or not a block
<?php
/**
* This function checks if at least one field is completed by BO
*
* @param array|string $fields the list of ACF fields to test, an array or a string of text separated by a comma
* @param mixed $object the post_id of which the value is saved against
* @param bool $is_sub_field
*
* @return bool
*/
@dgoze
dgoze / sync-parent-categories-acf.php
Created July 24, 2024 17:59 — forked from khromov/sync-parent-categories-acf.php
Sync taxonomy categories with ACF taxonomy field in WordPress
<?php
add_action('save_post', array($this, 'mark_parent_categories'), 11);
/**
* Marks parent categories automatically. Works with the ACF taxonomy selector as well.
*
* @return mixed
*/
function mark_parent_categories($post_id) {
global $post;