Tuesday, June 26th, 2018
Make sure your image field is set to an array in ACF and then use the below.
‘150px’ is the maximum width your image will ever display.
Click the link to view the code
Tags: ACF, Functions, Responsive images, SRCSET, WordPress
Posted in PHP, WordPress | No Comments »
Monday, April 16th, 2018
Function for grabbing image from post and using it instead of a featured image for example.
Add this to functions.php
// Get URL of first image in a post
function catch_that_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$matches[1][0] = '';
if(preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches)){
$first_img = $matches[1][0];
}
// no image found display default image instead
return $first_img;
}
And call in the theme with
<img src="<?php echo catch_that_image() ?>" onerror="this.style.display = 'none';"/>
Tags: catch that image, featured image, first image, first image from post, Functions, PHP, wordperss
Posted in PHP, WordPress | No Comments »
Thursday, February 8th, 2018
If you want to pre-disable Gutenberg for when it launches, install the following plugin, activate and untick the checkbox in the settings: https://wordpress.org/plugins/classic-editor/
If you also want to avoid the 5.0 update, you can always hide the update banner:
//Add to functions.php file to remove WordPress update notice
function hide_update_notice() {
remove_action( 'admin_notices', 'update_nag', 3 );
}
add_action( 'admin_notices', 'hide_update_notice', 1 );
Tags: Functions, Gutenberg, Remove, WordPress
Posted in WordPress | No Comments »
Tuesday, January 9th, 2018
Add this to you wp-config.php file and change the number for how many revisions you want to limit your pages to:
define('WP_POST_REVISIONS', 10);
Or use the below to globally turn off post revisions:
define('WP_POST_REVISIONS', false);
Tags: Code help, Functions, Matt Seymour, Post, Revisions, Support, WordPress, WP, WP config, wp_post_revisions
Posted in PHP, WordPress | No Comments »
Wednesday, November 30th, 2016
Add this to functions.php
// Pick out the version number from scripts and styles
function remove_version_from_style_js( $src ) {
if ( strpos( $src, 'ver=' . get_bloginfo( 'version' ) ) )
$src = remove_query_arg( 'ver', $src );
return $src;
}
add_filter( 'style_loader_src', 'remove_version_from_style_js');
add_filter( 'script_loader_src', 'remove_version_from_style_js');
Tags: Functions, PHP, Remove, Script, Style, Ver, Version, WordPress
Posted in PHP, WordPress | No Comments »
Thursday, October 6th, 2016
Add to functions.php
// REMOVE WP EMOJI
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' );
Tags: Emoji code, Functions, Header, PHP, WordPress
Posted in PHP, WordPress | No Comments »
Friday, September 30th, 2016
Add to functions.php file.
function ld_new_excerpt_more($more) {
global $post;
return '...';
}
add_filter('excerpt_more', 'ld_new_excerpt_more');
Tags: Ellipses, Excerpt, Functions, WordPress
Posted in PHP, WordPress | No Comments »
Friday, September 30th, 2016
Add this to the functions.php file.
add_theme_support( 'post-thumbnails' );
Tags: Functions, PHP, Support, Thumbnails, WordPress
Posted in PHP, WordPress | No Comments »
Thursday, August 18th, 2016
Tags: Functions, Name, Query, Tax, Taxonomy, Term, Terms, WordPress
Posted in PHP, WordPress | No Comments »