Change Merryweather font in twentysixteen using php
-
Hello. Please can someone advise on the following, I want to change the Google font ‘Merryweather’ in WordPress twenty sixteen to SpicyRice.?
I set up a twenty sixteen Child theme which is working and can be edited through appearance>editor. ???I can’t get the the next stage to work. My functions.php edit in the child theme results in the php appearing in the masthead area.
The twentysixteen functions.php is here on GitHub.
https://github.com/WordPress/twentysixteen/blob/master/functions.php
A complete copy of my new functions file; is below.
<?php
function theme_enqueue_styles() {$parent_style = ‘parent-style’;
wp_enqueue_style( $parent_style, get_template_directory_uri() . ‘/style.css’ );
wp_enqueue_style( ‘child-style’,
get_stylesheet_directory_uri() . ‘/style.css’,
array( $parent_style )
);
}
add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’ );
?>
<?php
function twentysixteen_fonts_url() {
$fonts_url = ”;
$fonts = array();
$subsets = ‘latin,latin-ext’;/* translators: If there are characters in your language that are not supported by Spicy+Rice, translate this to ‘off’. Do not translate into your own language. */
if ( ‘off’ !== _x( ‘on’, ‘Spicy+Rice font: on or off’, ‘twentysixteen’ ) ) {
$fonts[] = ‘Spicy+Rice:400’;
}if ( $fonts ) {
$fonts_url = add_query_arg( array(
‘family’ => urlencode( implode( ‘|’, $fonts ) ),
‘subset’ => urlencode( $subsets ),
), ‘https://fonts.googleapis.com/css’ );
}return $fonts_url;
}
endif;
-
what is your URL?
is the font loading? have you changed the css to reflect the call to the font?
Hello. Thanks for looking.
No the font is not loading, this much of the php is hidden above the masthead.
* * Register Google fonts for Twenty Sixteen. * * Create your own twentysixteen_fonts_url() function to override in a child theme. * * @since Twenty Sixteen 1.0 * * @return string Google fonts URL for the theme. */ function twentysixteen_fonts_url() { $fonts_url = ”; $fonts = array(); $subsets = ‘latin,latin-ext’; /* translators: If there are characters in your language that are not supported by Spicy+Rice, translate this to ‘off’. Do not translate into your own language. */ if ( ‘off’ !== _x( ‘on’, ‘Spicy+Rice font: on or off’, ‘twentysixteen’ ) ) { $fonts[] = ‘Spicy+Rice:400’; } return $fonts_url; } endif;
Skip to contentYes I have changed the css. And seen the other changes work.
.site-title a {
color: red !important;
font-family: Spicy+Rice !important;
}
.site-title {
font-size: 34px !important;
}I am developing on Mac in MAMP so there is no url. I will happily pot screenshots if needs.
Best regards Nick.
Instead of using the functions file why dont you just add this to your header.php in the head tags?
<link href='https://fonts.googleapis.com/css?family=Spicy+Rice' rel='stylesheet' type='text/css'>
see here, #3 under the ‘standard’ tab
https://www.google.com/fonts#UsePlace:use/Collection:Spicy+Riceand for css google suggests this:
.site-title { font-family: 'Spicy Rice', cursive; }
see here, #4
https://www.google.com/fonts#UsePlace:use/Collection:Spicy+RiceHi Thanks again. I was hoping to eliminate the loading of Merryweather and replace it with Spicy Rice. I read a hint in the functions.php file, in twenty sixteen that stated fonts could be changed there.
If I was to follow your kind instructions and add the font call to header.php in my child theme.
How would I implement that through my child theme?
Best regards Nick.
create a copy of your header.php file from your parent theme and place it in the directory of your child theme. When using a child theme wp always searches for files there first. it then will move to the parent theme if the child does not have its own.
Once you copy the header.php file you can safely make changes to it and they will be a part of your child theme.
if you have a functions file in your child theme you can look at the wp_dequeue_style or wp_dequeue_script function to stop meriweather from loading.
https://codex.www.ads-software.com/Function_Reference/wp_dequeue_style
https://codex.www.ads-software.com/Function_Reference/wp_dequeue_scriptThanks again. That has worked a treat.
Not sure about the syntax to dequeue the script. In my child functions.php
<?php function theme_enqueue_styles() { $parent_style = 'parent-style'; wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' ); wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( $parent_style ) ); } add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); ?>
Sorry about the huge file that follows, ‘functions.php’ I don’t know how reference the merry weather font, or how to include it with functions.php in my child Theme. Surely I’m not meant to copy to whole file?
<?php /** * Twenty Sixteen functions and definitions * * Set up the theme and provides some helper functions, which are used in the * theme as custom template tags. Others are attached to action and filter * hooks in WordPress to change core functionality. * * When using a child theme you can override certain functions (those wrapped * in a function_exists() call) by defining them first in your child theme's * functions.php file. The child theme's functions.php file is included before * the parent theme's file, so the child theme functions would be used. * * @link https://codex.www.ads-software.com/Theme_Development * @link https://codex.www.ads-software.com/Child_Themes * * Functions that are not pluggable (not wrapped in function_exists()) are * instead attached to a filter or action hook. * * For more information on hooks, actions, and filters, * {@link https://codex.www.ads-software.com/Plugin_API} * * @package WordPress * @subpackage Twenty_Sixteen * @since Twenty Sixteen 1.0 */ /** * Twenty Sixteen only works in WordPress 4.4 or later. */ if ( version_compare( $GLOBALS['wp_version'], '4.4-alpha', '<' ) ) { require get_template_directory() . '/inc/back-compat.php'; } if ( ! function_exists( 'twentysixteen_setup' ) ) : /** * Sets up theme defaults and registers support for various WordPress features. * * Note that this function is hooked into the after_setup_theme hook, which * runs before the init hook. The init hook is too late for some features, such * as indicating support for post thumbnails. * * Create your own twentysixteen_setup() function to override in a child theme. * * @since Twenty Sixteen 1.0 */ function twentysixteen_setup() { /* * Make theme available for translation. * Translations can be filed in the /languages/ directory. * If you're building a theme based on Twenty Sixteen, use a find and replace * to change 'twentysixteen' to the name of your theme in all the template files */ load_theme_textdomain( 'twentysixteen', get_template_directory() . '/languages' ); // Add default posts and comments RSS feed links to head. add_theme_support( 'automatic-feed-links' ); /* * Let WordPress manage the document title. * By adding theme support, we declare that this theme does not use a * hard-coded <title> tag in the document head, and expect WordPress to * provide it for us. */ add_theme_support( 'title-tag' ); /* * Enable support for Post Thumbnails on posts and pages. * * @link https://codex.www.ads-software.com/Function_Reference/add_theme_support#Post_Thumbnails */ add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 1200, 9999 ); // This theme uses wp_nav_menu() in two locations. register_nav_menus( array( 'primary' => __( 'Primary Menu', 'twentysixteen' ), 'social' => __( 'Social Links Menu', 'twentysixteen' ), ) ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', ) ); /* * Enable support for Post Formats. * * See: https://codex.www.ads-software.com/Post_Formats */ add_theme_support( 'post-formats', array( 'aside', 'image', 'video', 'quote', 'link', 'gallery', 'status', 'audio', 'chat', ) ); /* * This theme styles the visual editor to resemble the theme style, * specifically font, colors, icons, and column width. */ add_editor_style( array( 'css/editor-style.css', twentysixteen_fonts_url() ) ); } endif; // twentysixteen_setup add_action( 'after_setup_theme', 'twentysixteen_setup' ); /** * Sets the content width in pixels, based on the theme's design and stylesheet. * * Priority 0 to make it available to lower priority callbacks. * * @global int $content_width * * @since Twenty Sixteen 1.0 */ function twentysixteen_content_width() { $GLOBALS['content_width'] = apply_filters( 'twentysixteen_content_width', 840 ); } add_action( 'after_setup_theme', 'twentysixteen_content_width', 0 ); /** * Registers a widget area. * * @link https://developer.www.ads-software.com/reference/functions/register_sidebar/ * * @since Twenty Sixteen 1.0 */ function twentysixteen_widgets_init() { register_sidebar( array( 'name' => __( 'Sidebar', 'twentysixteen' ), 'id' => 'sidebar-1', 'description' => __( 'Add widgets here to appear in your sidebar.', 'twentysixteen' ), 'before_widget' => '<section id="%1$s" class="widget %2$s">', 'after_widget' => '</section>', 'before_title' => '<h2 class="widget-title">', 'after_title' => '</h2>', ) ); register_sidebar( array( 'name' => __( 'Content Bottom 1', 'twentysixteen' ), 'id' => 'sidebar-2', 'description' => __( 'Appears at the bottom of the content on posts and pages.', 'twentysixteen' ), 'before_widget' => '<section id="%1$s" class="widget %2$s">', 'after_widget' => '</section>', 'before_title' => '<h2 class="widget-title">', 'after_title' => '</h2>', ) ); register_sidebar( array( 'name' => __( 'Content Bottom 2', 'twentysixteen' ), 'id' => 'sidebar-3', 'description' => __( 'Appears at the bottom of the content on posts and pages.', 'twentysixteen' ), 'before_widget' => '<section id="%1$s" class="widget %2$s">', 'after_widget' => '</section>', 'before_title' => '<h2 class="widget-title">', 'after_title' => '</h2>', ) ); } add_action( 'widgets_init', 'twentysixteen_widgets_init' ); if ( ! function_exists( 'twentysixteen_fonts_url' ) ) : /** * Register Google fonts for Twenty Sixteen. * * Create your own twentysixteen_fonts_url() function to override in a child theme. * * @since Twenty Sixteen 1.0 * * @return string Google fonts URL for the theme. */ function twentysixteen_fonts_url() { $fonts_url = ''; $fonts = array(); $subsets = 'latin,latin-ext'; /* translators: If there are characters in your language that are not supported by Merriweather, translate this to 'off'. Do not translate into your own language. */ if ( 'off' !== _x( 'on', 'Merriweather font: on or off', 'twentysixteen' ) ) { $fonts[] = 'Merriweather:400,700,900,400italic,700italic,900italic'; } /* translators: If there are characters in your language that are not supported by Montserrat, translate this to 'off'. Do not translate into your own language. */ if ( 'off' !== _x( 'on', 'Montserrat font: on or off', 'twentysixteen' ) ) { $fonts[] = 'Montserrat:400,700'; } /* translators: If there are characters in your language that are not supported by Inconsolata, translate this to 'off'. Do not translate into your own language. */ if ( 'off' !== _x( 'on', 'Inconsolata font: on or off', 'twentysixteen' ) ) { $fonts[] = 'Inconsolata:400'; } if ( $fonts ) { $fonts_url = add_query_arg( array( 'family' => urlencode( implode( '|', $fonts ) ), 'subset' => urlencode( $subsets ), ), 'https://fonts.googleapis.com/css' ); } return $fonts_url; } endif; /** * Handles JavaScript detection. * * Adds a <code>js</code> class to the root <code><html></code> element when JavaScript is detected. * * @since Twenty Sixteen 1.0 */ function twentysixteen_javascript_detection() { echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\n"; } add_action( 'wp_head', 'twentysixteen_javascript_detection', 0 ); /** * Enqueues scripts and styles. * * @since Twenty Sixteen 1.0 */ function twentysixteen_scripts() { // Add custom fonts, used in the main stylesheet. wp_enqueue_style( 'twentysixteen-fonts', twentysixteen_fonts_url(), array(), null ); // Add Genericons, used in the main stylesheet. wp_enqueue_style( 'genericons', get_template_directory_uri() . '/genericons/genericons.css', array(), '3.4.1' ); // Theme stylesheet. wp_enqueue_style( 'twentysixteen-style', get_stylesheet_uri() ); // Load the Internet Explorer specific stylesheet. wp_enqueue_style( 'twentysixteen-ie', get_template_directory_uri() . '/css/ie.css', array( 'twentysixteen-style' ), '20150930' ); wp_style_add_data( 'twentysixteen-ie', 'conditional', 'lt IE 10' ); // Load the Internet Explorer 8 specific stylesheet. wp_enqueue_style( 'twentysixteen-ie8', get_template_directory_uri() . '/css/ie8.css', array( 'twentysixteen-style' ), '20151230' ); wp_style_add_data( 'twentysixteen-ie8', 'conditional', 'lt IE 9' ); // Load the Internet Explorer 7 specific stylesheet. wp_enqueue_style( 'twentysixteen-ie7', get_template_directory_uri() . '/css/ie7.css', array( 'twentysixteen-style' ), '20150930' ); wp_style_add_data( 'twentysixteen-ie7', 'conditional', 'lt IE 8' ); // Load the html5 shiv. wp_enqueue_script( 'twentysixteen-html5', get_template_directory_uri() . '/js/html5.js', array(), '3.7.3' ); wp_script_add_data( 'twentysixteen-html5', 'conditional', 'lt IE 9' ); wp_enqueue_script( 'twentysixteen-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151112', true ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } if ( is_singular() && wp_attachment_is_image() ) { wp_enqueue_script( 'twentysixteen-keyboard-image-navigation', get_template_directory_uri() . '/js/keyboard-image-navigation.js', array( 'jquery' ), '20151104' ); } wp_enqueue_script( 'twentysixteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20151204', true ); wp_localize_script( 'twentysixteen-script', 'screenReaderText', array( 'expand' => __( 'expand child menu', 'twentysixteen' ), 'collapse' => __( 'collapse child menu', 'twentysixteen' ), ) ); } add_action( 'wp_enqueue_scripts', 'twentysixteen_scripts' ); /** * Adds custom classes to the array of body classes. * * @since Twenty Sixteen 1.0 * * @param array $classes Classes for the body element. * @return array (Maybe) filtered body classes. */ function twentysixteen_body_classes( $classes ) { // Adds a class of custom-background-image to sites with a custom background image. if ( get_background_image() ) { $classes[] = 'custom-background-image'; } // Adds a class of group-blog to sites with more than 1 published author. if ( is_multi_author() ) { $classes[] = 'group-blog'; } // Adds a class of no-sidebar to sites without active sidebar. if ( ! is_active_sidebar( 'sidebar-1' ) ) { $classes[] = 'no-sidebar'; } // Adds a class of hfeed to non-singular pages. if ( ! is_singular() ) { $classes[] = 'hfeed'; } return $classes; } add_filter( 'body_class', 'twentysixteen_body_classes' ); /** * Converts a HEX value to RGB. * * @since Twenty Sixteen 1.0 * * @param string $color The original color, in 3- or 6-digit hexadecimal form. * @return array Array containing RGB (red, green, and blue) values for the given * HEX code, empty array otherwise. */ function twentysixteen_hex2rgb( $color ) { $color = trim( $color, '#' ); if ( strlen( $color ) === 3 ) { $r = hexdec( substr( $color, 0, 1 ).substr( $color, 0, 1 ) ); $g = hexdec( substr( $color, 1, 1 ).substr( $color, 1, 1 ) ); $b = hexdec( substr( $color, 2, 1 ).substr( $color, 2, 1 ) ); } else if ( strlen( $color ) === 6 ) { $r = hexdec( substr( $color, 0, 2 ) ); $g = hexdec( substr( $color, 2, 2 ) ); $b = hexdec( substr( $color, 4, 2 ) ); } else { return array(); } return array( 'red' => $r, 'green' => $g, 'blue' => $b ); } /** * Custom template tags for this theme. */ require get_template_directory() . '/inc/template-tags.php'; /** * Customizer additions. */ require get_template_directory() . '/inc/customizer.php'; /** * Add custom image sizes attribute to enhance responsive image functionality * for content images * * @since Twenty Sixteen 1.0 * * @param string $sizes A source size value for use in a 'sizes' attribute. * @param array $size Image size. Accepts an array of width and height * values in pixels (in that order). * @return string A source size value for use in a content image 'sizes' attribute. */ function twentysixteen_content_image_sizes_attr( $sizes, $size ) { $width = $size[0]; 840 <= $width && $sizes = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px'; if ( 'page' === get_post_type() ) { 840 > $width && $sizes = '(max-width: ' . $width . 'px) 85vw, ' . $width . 'px'; } else { 840 > $width && 600 <= $width && $sizes = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px'; 600 > $width && $sizes = '(max-width: ' . $width . 'px) 85vw, ' . $width . 'px'; } return $sizes; } add_filter( 'wp_calculate_image_sizes', 'twentysixteen_content_image_sizes_attr', 10 , 2 ); /** * Add custom image sizes attribute to enhance responsive image functionality * for post thumbnails * * @since Twenty Sixteen 1.0 * * @param array $attr Attributes for the image markup. * @param int $attachment Image attachment ID. * @param array $size Registered image size or flat array of height and width dimensions. * @return string A source size value for use in a post thumbnail 'sizes' attribute. */ function twentysixteen_post_thumbnail_sizes_attr( $attr, $attachment, $size ) { if ( 'post-thumbnail' === $size ) { is_active_sidebar( 'sidebar-1' ) && $attr['sizes'] = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 60vw, (max-width: 1362px) 62vw, 840px'; ! is_active_sidebar( 'sidebar-1' ) && $attr['sizes'] = '(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 88vw, 1200px'; } return $attr; } add_filter( 'wp_get_attachment_image_attributes', 'twentysixteen_post_thumbnail_sizes_attr', 10 , 3 ); /** * Modifies tag cloud widget arguments to have all tags in the widget same font size. * * @since Twenty Sixteen 1.1 * * @param array $args Arguments for tag cloud widget. * @return array A new modified arguments. */ function twentysixteen_widget_tag_cloud_args( $args ) { $args['largest'] = 1; $args['smallest'] = 1; $args['unit'] = 'em'; return $args; } add_filter( 'widget_tag_cloud_args', 'twentysixteen_widget_tag_cloud_args' );
it looks like that google fonts function is a pluggable function in twentysixteen theme. If you call that function in your child theme’s function first it wont, or shouldn’t load from your parent theme’s funtion file.
function twentysixteen_fonts_url() { //add code for new function here }
Thanks for looking again. Does the info’ mean I can take the code referring to the font from functions.php (not child), and not load the previous fonts, and at the same time request my choice of fonts.
Or is it better to load the fonts in the header.php (child) and unload the old ones from functions.php?
I really appreciate your help with this, I am getting a much better understanding of child themes. and seeing how elegant coding can be with WP.
Best regards Nick.
If the answer to the above is yes. Below would be the new functions.php (child) Only if I run it through php checker I get an error on line 12, add_action( ‘wp_enq….. I have not changed the fonts yet so I know the syntax is correct. Thanks.
<?php function theme_enqueue_styles() { $parent_style = 'parent-style'; wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' ); wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( $parent_style ) ); } add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); function twentysixteen_fonts_url() { $fonts_url = ''; $fonts = array(); $subsets = 'latin,latin-ext'; /* translators: If there are characters in your language that are not supported by Merriweather, translate this to 'off'. Do not translate into your own language. */ if ( 'off' !== _x( 'on', 'Merriweather font: on or off', 'twentysixteen' ) ) { $fonts[] = 'Merriweather:400,700,900,400italic,700italic,900italic'; } /* translators: If there are characters in your language that are not supported by Montserrat, translate this to 'off'. Do not translate into your own language. */ if ( 'off' !== _x( 'on', 'Montserrat font: on or off', 'twentysixteen' ) ) { $fonts[] = 'Montserrat:400,700'; } /* translators: If there are characters in your language that are not supported by Inconsolata, translate this to 'off'. Do not translate into your own language. */ if ( 'off' !== _x( 'on', 'Inconsolata font: on or off', 'twentysixteen' ) ) { $fonts[] = 'Inconsolata:400'; } if ( $fonts ) { $fonts_url = add__arg( array( 'family' => urlencode( implode( '|', $fonts ) ), 'subset' => urlencode( $subsets ), ), 'https://fonts.googleapis.com/css' ); } return $fonts_url; }
that looks like the function that is in your parent theme. you shouldn’t copy it in your child.
I guess I need to learn php in order to continue with WP. It just doesn’t seem logical to stray from the path the author intended to call fonts, also I don’t have the php writing skills to piece together code to dequeue the authors fonts. Thanks very much for your help. I will revisit after some further reading regarding best practice. Best regards Nick.
Ok after some further reading, this is best practice. This code dequeued the fonts in twentysixteen. I pasted in to the child theme functions.php as instructions above and ‘bingo’
function wp_dequeue_google_fonts() { wp_dequeue_style( 'twentysixteen-fonts' ); } add_action( 'wp_enqueue_scripts', 'wp_dequeue_google_fonts', 20 );
The full child theme functions.php follows for anyone on the same learning curve.
<?php function theme_enqueue_styles() { $parent_style = 'parent-style'; wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' ); wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( $parent_style ) ); } add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); function wp_dequeue_google_fonts() { wp_dequeue_style( 'twentysixteen-fonts' ); } add_action( 'wp_enqueue_scripts', 'wp_dequeue_google_fonts', 20 );
Thankyou Mr Case.
So Grateful to Mr Case I thought I would compile this as a tutorial in one post.
How to change the fonts in twentysixteen.
If you are not skilled in php this is for you. read the code in the the files and you can see where things are referenced and it is logical where to write your edits.
Make all the files in one go from this post. Then switch to the twentysixteen child theme you have created.
Below is a list of the files you will make, then a description of what they will do, and then the files you will copy.
1 / make a new directory/folder in your themes folder called;
twentysixteen-child2 / copy and paste the functions.php code into a plain text file called;
functions.php save this in the directory/folder3 / copy and paste the style.css code into a plain text file called;
style.css4 / copy and paste the header.php code into a plain text file called;
header.php1 / This is a folder / directory
2 / the functions.php will stop the theme fonts from loading and keeps the download time low.
3 / style.css Is where you must change the css to call the new fonts throughout the site.
(there is an example inside, a full list is the last item in this post.)4 / header.php is where you will call your new font choices from the Google fonts repository.
functions.php
<?php function theme_enqueue_styles() { $parent_style = 'parent-style'; wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' ); wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( $parent_style ) ); } add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); function wp_dequeue_google_fonts() { wp_dequeue_style( 'twentysixteen-fonts' ); } add_action( 'wp_enqueue_scripts', 'wp_dequeue_google_fonts', 20 );
style.css
/* Theme Name: Twenty Sixteen Child Theme URI: https://example.com/twenty-sifteen-child/ Description: Twenty Sixteen Child Theme Author: John Doe Author URI: https://example.com Template: twentysixteen Version: 1.0.0 License: GNU General Public License v2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready Text Domain: twenty-sixteen-child */ .site-title { font-family: 'Spicy Rice', cursive; } .site-title { font-size: 34px !important; }
header.php
<?php /** * The template for displaying the header * * Displays all of the head element and everything up until the "site-content" div. * * @package WordPress * @subpackage Twenty_Sixteen * @since Twenty Sixteen 1.0 */ ?><!DOCTYPE html> <html <?php language_attributes(); ?> class="no-js"> <head> <link href='https://fonts.googleapis.com/css?family=Spicy+Rice' rel='stylesheet' type='text/css'> <meta charset="<?php bloginfo( 'charset' ); ?>"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="profile" href="https://gmpg.org/xfn/11"> <?php if ( is_singular() && pings_open( get_queried_object() ) ) : ?> <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>"> <?php endif; ?> <?php wp_head(); ?> </head> <body <?php body_class(); ?>> <div id="page" class="site"> <div class="site-inner"> <a class="skip-link screen-reader-text" href="#content"><?php _e( 'Skip to content', 'twentysixteen' ); ?></a> <header id="masthead" class="site-header" role="banner"> <div class="site-header-main"> <div class="site-branding"> <?php if ( is_front_page() && is_home() ) : ?> <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1> <?php else : ?> <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></p> <?php endif; $description = get_bloginfo( 'description', 'display' ); if ( $description || is_customize_preview() ) : ?> <p class="site-description"><?php echo $description; ?></p> <?php endif; ?> </div><!-- .site-branding --> <?php if ( has_nav_menu( 'primary' ) || has_nav_menu( 'social' ) ) : ?> <button id="menu-toggle" class="menu-toggle"><?php _e( 'Menu', 'twentysixteen' ); ?></button> <div id="site-header-menu" class="site-header-menu"> <?php if ( has_nav_menu( 'primary' ) ) : ?> <nav id="site-navigation" class="main-navigation" role="navigation" aria-label="<?php esc_attr_e( 'Primary Menu', 'twentysixteen' ); ?>"> <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'primary-menu', ) ); ?> </nav><!-- .main-navigation --> <?php endif; ?> <?php if ( has_nav_menu( 'social' ) ) : ?> <nav id="social-navigation" class="social-navigation" role="navigation" aria-label="<?php esc_attr_e( 'Social Links Menu', 'twentysixteen' ); ?>"> <?php wp_nav_menu( array( 'theme_location' => 'social', 'menu_class' => 'social-links-menu', 'depth' => 1, 'link_before' => '<span class="screen-reader-text">', 'link_after' => '</span>', ) ); ?> </nav><!-- .social-navigation --> <?php endif; ?> </div><!-- .site-header-menu --> <?php endif; ?> </div><!-- .site-header-main --> <?php if ( get_header_image() ) : ?> <?php /** * Filter the default twentysixteen custom header sizes attribute. * * @since Twenty Sixteen 1.0 * * @param string $custom_header_sizes sizes attribute * for Custom Header. Default '(max-width: 709px) 85vw, * (max-width: 909px) 81vw, (max-width: 1362px) 88vw, 1200px'. */ $custom_header_sizes = apply_filters( 'twentysixteen_custom_header_sizes', '(max-width: 709px) 85vw, (max-width: 909px) 81vw, (max-width: 1362px) 88vw, 1200px' ); ?> <div class="header-image"> <a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"> <img src="<?php header_image(); ?>" srcset="<?php echo esc_attr( wp_get_attachment_image_srcset( get_custom_header()->attachment_id ) ); ?>" sizes="<?php echo esc_attr( $custom_header_sizes ); ?>" width="<?php echo esc_attr( get_custom_header()->width ); ?>" height="<?php echo esc_attr( get_custom_header()->height ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>"> </a> </div><!-- .header-image --> <?php endif; // End header image check. ?> </header><!-- .site-header --> <div id="content" class="site-content">
This last item is a list of css references from twentysixteen.
1. If you want to remove space from above the Site Title #masthead { padding-top: 0px !important; padding-bottom: 12px !important; } 2. Change Site title’s font color and size .site-title a { color: red !important; font-family: times new roman !important; } .site-title { font-size: 34px !important; } ? 3. If you want to make Site description bold, change font, font color or size in twenty sixteen theme .site-description { color: blue !important ; font-size: 14px !important; font-weight: bold !important; font-family: times new roman !important; } 4)If you want to hide Site description to show in the header in twenty sixteen theme .site-description { display:none !important; } 5) If u want to change your blog post’s or any of ur page’s title’s font, font color, size .entry-title, .entry-title a { color: red !important; font-size: 25px !important; font-weight: 500 !important; font-family: times new roman !important; } 6. From individual blog posts if you want to remove the Category and tags showing on the left of the post in twenty sixteen theme .single-post .entry-footer { display: none; } .single-post .entry-content { width: 100% !important; } 7. If you want to change Individual blog post’s Category or tag’s or Posted On’s font,font size, color ** For posted on .single-post .entry-footer .posted-on a { color: #000 !important; font-weight: bold; font-size: 14px !important; } ** For category links .single-post .entry-footer .cat-links a { color: #000 !important; font-weight: bold; font-size: 14px !important; } ** For tag links .single-post .entry-footer .tags-links a { color: #000 !important; font-weight: bold; font-size: 14px !important; } ? 8. From Individual blog post if you dont want to show the Related Post at the bottom of the post .single-post #jp-relatedposts { display: none !important; } 9. If you want to change Font, font color,size,weight of Related post in twenty sixteen theme .jp-relatedposts-post-title, .jp-relatedposts-post-title a { color: red !important; font-weight: 400 !important; font-family: times new roman !important; font-size: 14px !important; } ?? 10. If you want to change font,font color, size of sidebar widget title in twenty sixteen theme .widget .widget-title { margin-bottom: 1.3125em; font-size: 17px !important; color: red !important; font-family: times new roman !important; } 11. If you want to change sidebar widget’s link color, size, font family etc .widget li a, .widget a { color: red !important; font-family: times new roman !important; font-weight: 700; font-size: 14px !important; } 12. if you want to remove Category Links (cat links) and Tag links from homepage in twenty sixteen theme please use the following code .home .cat-links, .home .tags-links { display: none !important; }
Do you know the code to change the FONT on the the nav menu?
First off, I would like to say thank you to Nick and Mr Case for their contributions to this post because it has the ability to improve your mobile user score as well. I encountered the same issue and it was impacting my mobile user score by 20 points, it was 99/80 and after I edited my functions.php in my Child Theme my score went to 100/100, but my view-port script was edited by google to meet their new standard. I am a novice at WP but I have been through living hell for almost 3 weeks after 4.7 was accidentally pushed to me by WP Engine. I hope WordPress is addressing the issue because my site is hosted by WP Engine and it took me almost 2 weeks to get their attention but I was plagued with one problem after another until I told them to reverted me back to 4.6.1 using Theme Twenty Sixteen. A manager called me one day and said you have made a big fuss and pointing the finger and I politely told him, I have a play site hosted by Go-Daddy and it happened to a lot of customers so if the responsibility lies on the website owner then you might lose a lot of their customers as well so I was not the only one that was impacted by it. Your business is hosting websites and if you push or force customers to update and it breaks their site then I view it as your problem, loosing customer is lost revenue in my books.
Thanks very much to all,
Larry Harrison
- The topic ‘Change Merryweather font in twentysixteen using php’ is closed to new replies.