enqueue Google-fonts link in function.php
ik heb in mij function.php bestand deze code ingevoerd :
Code (php)
1
2
3
2
3
function auto_repair_scripts() {
//add Google fonts Merriweather
wp_enqueue_style( 'auto-repair-google-fonts, 'https://fonts.googleapis.com/css?family=Merriweather:400,400i,700,700i' );
//add Google fonts Merriweather
wp_enqueue_style( 'auto-repair-google-fonts, 'https://fonts.googleapis.com/css?family=Merriweather:400,400i,700,700i' );
maar ik krijg foutmelding.
normaal gesproken de link is :<link href="https://fonts.googleapis.com/css?family=Merriweather:400,400i,700,700i" rel="stylesheet">
ik kan deze link in header.php toevoegen maar ik wil het enqueue in function.php en het moet kunnen.
een deel van mij function.php code is:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function auto_repair_stylesheets() {
wp_register_style( 'style.css', get_template_directory_uri() . '/style.css', array(), null, 'all' );
wp_register_style( 'app.css', get_template_directory_uri() . '/app.css', array(), null, 'all' );
wp_enqueue_style( 'style.css' );
wp_enqueue_style( 'app.css' );
}
add_action( 'wp_enqueue_scripts', 'auto_repair_stylesheets' );
/**
* Enqueue scripts and styles.
*/
function auto_repair_scripts() {
//add Google fonts Merriweather
wp_enqueue_style( 'auto-repair-google-fonts, 'https://fonts.googleapis.com/css?family=Merriweather:400,400i,700,700i' );
wp_enqueue_script( 'auto-repair-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true );
wp_enqueue_script( 'auto-repair-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true );
wp_register_style( 'style.css', get_template_directory_uri() . '/style.css', array(), null, 'all' );
wp_register_style( 'app.css', get_template_directory_uri() . '/app.css', array(), null, 'all' );
wp_enqueue_style( 'style.css' );
wp_enqueue_style( 'app.css' );
}
add_action( 'wp_enqueue_scripts', 'auto_repair_stylesheets' );
/**
* Enqueue scripts and styles.
*/
function auto_repair_scripts() {
//add Google fonts Merriweather
wp_enqueue_style( 'auto-repair-google-fonts, 'https://fonts.googleapis.com/css?family=Merriweather:400,400i,700,700i' );
wp_enqueue_script( 'auto-repair-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true );
wp_enqueue_script( 'auto-repair-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true );
hoe ik kan deze probleem oplossen?
dank u wel
Johannes
Gokje: Zet eens een ' na auto-repair-google-fonts.
ik heb het deze code (auto-repair-google-fonts) in de voorbeeld boven function.php:
Code (php)
1
wp_enqueue_style( 'auto-repair-google-fonts, 'https://fonts.googleapis.com/css?family=Merriweather:400,400i,700,700i' );
het helpt niet auto_repair-google-fonts of auto-repair-google-fonts
johannes
Wat gebeurt er dan precies? Je hebt het over een error. Maar welke dan precies?
Johannes davidian op 28/11/2016 12:18:55:
En daar mist nog steeds de enkele quote.
parse error: syntax error, unexpected 'https' (T_STRING) in /mnt/web010/b0/48/56990848/htdocs/WordPress_SecureMode_01/wp-content/themes/auto-repair/functions.php on line 130
en de code in lijn 130 is :
Code (php)
1
wp_enqueue_style( 'auto_repair-google-fonts, 'http://fonts.googleapis.com/css?family=Merriweather:400,400i,700,700i' );
johannes
Zie boven.
U heb gelijk.
maar na invoeren deze font family style (Merriweather) in CSS als volgende:
Code (php)
1
2
3
4
5
2
3
4
5
html {
font-family:'Merriweather', serif;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
font-family:'Merriweather', serif;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
en
Code (php)
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
body,
button,
input,
select,
textarea {
color: #404040;
font-family: 'Merriweather', serif;
font-size: 16px;
font-size: 1rem;
line-height: 1.5;
}
button,
input,
select,
textarea {
color: #404040;
font-family: 'Merriweather', serif;
font-size: 16px;
font-size: 1rem;
line-height: 1.5;
}
Het letters style veranderd niet naar Merriweather style.
Mij function.php code is nu als volgende:
Code (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
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
/**
* Register style sheet.
*/
function auto_repair_stylesheets() {
wp_register_style( 'style.css', get_template_directory_uri() . '/style.css', array(), null, 'all' );
wp_register_style( 'app.css', get_template_directory_uri() . '/app.css', array(), null, 'all' );
wp_enqueue_style( 'style.css' );
wp_enqueue_style( 'app.css' );
}
add_action( 'wp_enqueue_scripts', 'auto_repair_stylesheets' );
/**
* Enqueue scripts and styles.
*/
function auto_repair_scripts() {
//add Google fonts Merriweather
wp_enqueue_style( 'auto-repair-google-fonts', 'https://fonts.googleapis.com/css?family=Merriweather:400,400i,700,700i' );
wp_enqueue_script( 'auto-repair-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true );
wp_enqueue_script( 'auto_repair-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'auto_repair_scripts' );
* Register style sheet.
*/
function auto_repair_stylesheets() {
wp_register_style( 'style.css', get_template_directory_uri() . '/style.css', array(), null, 'all' );
wp_register_style( 'app.css', get_template_directory_uri() . '/app.css', array(), null, 'all' );
wp_enqueue_style( 'style.css' );
wp_enqueue_style( 'app.css' );
}
add_action( 'wp_enqueue_scripts', 'auto_repair_stylesheets' );
/**
* Enqueue scripts and styles.
*/
function auto_repair_scripts() {
//add Google fonts Merriweather
wp_enqueue_style( 'auto-repair-google-fonts', 'https://fonts.googleapis.com/css?family=Merriweather:400,400i,700,700i' );
wp_enqueue_script( 'auto-repair-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true );
wp_enqueue_script( 'auto_repair-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'auto_repair_scripts' );
ik heb voor zekerheid de brouwser data gewist maar toch het probleem blijft hetzelfde de letters veranderd niet naar Merriweather!
wat kan het probleem zijn nu . is het probleem ligt in function.php code of ergens anders?
johannes
ik was ziek 2 dagen daarom ik heb geen reactie gegeven.
het fout was in underscores-thema zelf ,soms doet deze Wordpress thema rare dingen,mischien wordpress zelf doet soms rare dingen.
ik heb nieuwe thema geinstalleerd en de Google-fonts link ingevoerd in header.php :
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
/**
* The header for our theme.
*
* This is the template that displays all of the <head> section and everything up until <div id="content">
*
* @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
*
* @package Garage
*/
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link href="https://fonts.googleapis.com/css?family=Merriweather" rel="stylesheet">
<!-- Compressed CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/foundation/6.2.4/foundation.min.css">
<?php wp_head(); ?>
</head>
/**
* The header for our theme.
*
* This is the template that displays all of the <head> section and everything up until <div id="content">
*
* @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
*
* @package Garage
*/
?><!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="profile" href="http://gmpg.org/xfn/11">
<link href="https://fonts.googleapis.com/css?family=Merriweather" rel="stylesheet">
<!-- Compressed CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/foundation/6.2.4/foundation.min.css">
<?php wp_head(); ?>
</head>
het kan ook via importen in css bestand :
en derde manier is enqueue de Google-fonts in functions.php als volgende:
Code (php)
1
2
3
4
5
6
2
3
4
5
6
function load_fonts() {
wp_register_style('googleFonts', 'http://fonts.googleapis.com/css?family=Rock+Salt|Neucha');
wp_enqueue_style( 'googleFonts');
}
add_action('wp_print_styles', 'load_fonts');
wp_register_style('googleFonts', 'http://fonts.googleapis.com/css?family=Rock+Salt|Neucha');
wp_enqueue_style( 'googleFonts');
}
add_action('wp_print_styles', 'load_fonts');
de url voor hoe U kunt Google-fonts invoeren in Wordpress thema is :https://webdesignfromscratch.com/wordpress/using-google-web-fonts-with-wordpress-the-right-way/
dank u wel iedereen
Johannes