WP Improvements

// Remove query string from static resources function _remove_script_version( $src ){ $parts = explode( ‘?ver’, $src ); return $parts[0]; } add_filter( ‘script_loader_src’, ‘_remove_script_version’, 15, 1 ); add_filter( ‘style_loader_src’, ‘_remove_script_version’, 15, 1 ); // Turn off full screen editor if (is_admin())…Continue reading

Remove wrap from images in ACF editor

// Remove wrap from images in ACF editor function gc_remove_p_tags_around_images($content) { $contentWithFixedPTags = preg_replace_callback(‘/ ((?:.(?!p>))*?)(]*>)?\s*(]+>)()?(.*?)/is’, function($matches) { // image and (optional) link: $image = $matches[2] . $matches[3] . $matches[4]; // content before and after image. wrap in unless it’s empty…Continue reading

Blog ACF Blocks

// Custom Blocks add_action( ‘init’, ‘register_acf_blocks’ ); function register_acf_blocks() { register_block_type( __DIR__ . ‘/blocks/callout-list’ ); register_block_type( __DIR__ . ‘/blocks/blog-cta’ ); }Continue reading

Custom Blog Image Sizes

// Custom Image Sizes function abc($size_arr) { $size_arr = array( ‘related’ => __( ‘Related’, ‘uabb’ ), ‘blogpage’ => __( ‘Blog Page’, ‘uabb’ ), ); // Add your own size to this array. return $size_arr; } add_filter( ‘uabb_blog_posts_featured_image_sizes’, ‘abc’ ); add_filter(…Continue reading

Add image to rss feed

function rss_post_thumbnail($content) { global $post; if(has_post_thumbnail($post->ID)) { $content = ‘ ‘ . get_the_post_thumbnail($post->ID) . ‘ ‘ . get_the_content(); } return $content; } add_filter(‘the_excerpt_rss’, ‘rss_post_thumbnail’); add_filter(‘the_content_feed’, ‘rss_post_thumbnail’);Continue reading

Remove users from WP-JSON

add_filter(‘rest_endpoints’, function( $endpoints ) { if ( isset( $endpoints[‘/wp/v2/users’] ) ) { unset( $endpoints[‘/wp/v2/users’] ); } if ( isset( $endpoints[‘/wp/v2/users/(?P[\d]+)’] ) ) { unset( $endpoints[‘/wp/v2/users/(?P[\d]+)’] ); } return $endpoints; });Continue reading

“New” Badge for Recent Posts (copy)

add_filter( ‘the_title’, function ( $title, $id ) { if ( ! is_admin() && is_single( $id ) ) { $number_of_days = 7; $post_date = get_the_date( ‘U’, $id ); $current_date = current_time( ‘timestamp’ ); $date_diff = $current_date – $post_date; if ( $date_diff…Continue reading