Skip to content

Instantly share code, notes, and snippets.

define('WP_DEBUG_DISPLAY', false);
define('WP_DEBUG_LOG', true);
define( 'WP_DEBUG', false );
// Assuming your Media Library image has a post id of 42...
echo wp_get_attachment_image( 42, 'new-custom-size' );
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'new-custom-size' );
}
add_filter( 'image_size_names_choose', 'my_custom_sizes' );
function my_custom_sizes( $sizes ) {
return array_merge( $sizes, array(
'new-custom-size' => __( 'New Custom Size Name' ),
) );
}
add_image_size( 'new-custom-size', width, height, crop mode );
add_action( 'after_setup_theme', 'themename_setup' );
add_theme_support( 'post-thumbnails' );
<?php
if ( version_compare( $GLOBALS['wp_version'], '4.7-alpha', '<' ) ) {
require get_template_directory() . '/inc/back-compat.php';
return;
}
/**
* Sets up theme defaults and registers support for various WordPress features.
*