-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
61 lines (51 loc) · 1.88 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* Author Hemingway Child Theme
*
* A child theme for the Hemingway theme by Anders Noren
*
* Thanks to the following docs and tutorials:
* - https://developer.wordpress.org/themes/advanced-topics/child-themes/#3-enqueue-stylesheet
* - https://www.smashingmagazine.com/2016/01/create-customize-wordpress-child-theme/
*
* @package author-hemingway-child-theme
*/
/**
* Enqueue parent theme stylesheet, and stylesheet for this child theme.
*/
function my_theme_enqueue_styles() {
$parent_style = 'parent-style'; // This is the 'hemingway' theme.
wp_enqueue_style( $parent_style,
get_template_directory_uri() . '/style.css',
null,
wp_get_theme()->get( 'Version' )
);
wp_enqueue_style( 'child-style',
get_stylesheet_directory_uri() . '/style.css',
array( $parent_style ),
wp_get_theme()->get( 'Version' )
);
}
/**
* Removes width and height attributes from image tags
* From: https://wpscholar.com/blog/remove-image-size-attributes-wordpress-responsive/
*
* @param string $html the html of the image element.
*
* @return string
*/
function remove_image_size_attributes( $html ) {
return preg_replace( '/(width|height)="\d*"/', '', $html );
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
// Add support for 'excerpts' in Pages as well as Posts. This will be used so that pages have one-line descriptions.
add_post_type_support( 'page', 'excerpt' );
// Enable thumbnails.
add_theme_support( 'post-thumbnails' );
// Additional image sizes.
// Delete the next line if you do not need additional image sizes.
add_image_size( 'category-thumb', 450, 9999 ); // 300 pixels wide (and unlimited height)
// Remove image size attributes from post thumbnails.
add_filter( 'post_thumbnail_html', 'remove_image_size_attributes' );
// Remove image size attributes from images added to a WordPress post.
add_filter( 'image_send_to_editor', 'remove_image_size_attributes' );