Skip to content

Instantly share code, notes, and snippets.

View CreativeDive's full-sized avatar
🎯
Focusing

Martin Jost CreativeDive

🎯
Focusing
View GitHub Profile
@CreativeDive
CreativeDive / get_acf_fields_from_parent_block.php
Last active July 4, 2022 10:01
Possible solution to get the ACF field values by passing the field key, if we want to use the field data from the parent block inside a child block.
<?php
/*
* Example
*/
$my_acf_field = get_parent_block_acf_field( $context, 'field_5d4a9875f0c8d' );
$my_acf_field_2 = get_parent_block_acf_field( $context, 'field_622746ee08ac6' );
if( $my_acf_field ) {
@CreativeDive
CreativeDive / register_block_type.php
Created June 21, 2022 11:55
Possible solution to use the block.json way with ACF
<?php
/* DEFINE ACF BLOCKS */
if ( ! function_exists( 'my_acf_block_types' ) ) :
function my_acf_block_types() {
$color = '#2271b1';
@CreativeDive
CreativeDive / wordpress_image_compression_level
Last active January 28, 2020 08:05
Change the default WordPress image compression level.
if(!function_exists('wordpress_image_compression_quality')):
function wordpress_image_compression_quality($quality) {
// Default compression level
return 82; // <-- 100 is highest quality
}
endif;
@CreativeDive
CreativeDive / wordpress_post_excerpt_suffix
Last active January 28, 2020 08:08
Add a custom WordPress post excerpt suffix like "more" or "...".
if (!function_exists('wordpress_excerpt_more')):
function wordpress_excerpt_more($more) {
return ' ... ';
}
endif;
@CreativeDive
CreativeDive / wordpress_post_excerpt_length
Last active January 28, 2020 08:08
Customize the length of the WordPress post excerpt in words.
if( ! function_exists('wordpress_excerpt_length') ) :
function wordpress_excerpt_length( $length ) {
return 55; // <-- Word count
}
endif;