WordPress.org

Support

Support » Themes and Templates » [Resolved] How to change font using a child theme?

[Resolved] How to change font using a child theme?

  • Hi Michael Kloepzig,

    Thanks for a great theme. I’m trying to personalize my site using a child theme to Fluxipress. Please can you help me with the code snippet I need to place in my child theme’s function.php to be able to use a different google font then Open Sans? Have tried to dequeue the styles added in Fluxipress and added my own, but I can’t get it to work.

    Thanks in advance!

Viewing 13 replies - 1 through 13 (of 13 total)
  • Moderator Andrew Nevins

    @anevins

    Forum moderator

    To which font specifically?

    PT Sans and PT Sans Narrow for headers.

    Moderator Andrew Nevins

    @anevins

    Forum moderator

    Do you have that font? In which file type(s)?

    My plan was to load them from Google in these styles:

    http://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700,700italic|PT+Sans+Narrow:400

    Moderator Andrew Nevins

    @anevins

    Forum moderator

    Let’s see your site with the Child Theme activated .

    Unfortunately it’s not on a public server right now. However here is the code that I have in my functions.php.

    <?php
    
    // Child theme
    
    function child_dequeue_fonts() {
    	wp_dequeue_style('fluxpiress-css-fonts');
    }
    add_action('wp_enqueue_scripts', 'child_dequeue_fonts', 11);
    
    function child_fonts() {
    	wp_register_style(
    		'child-css-fonts',
    		'http' . ($_SERVER['SERVER_PORT'] == 443 ? 's' : '') . '://fonts.googleapis.com/css?family=PT+Sans:400,400italic,700,700italic|PT+Sans+Narrow:400'
    	);
    	wp_enqueue_style('child-css-fonts');
    }
    add_action('wp_enqueue_scripts', 'child_fonts');
    
    ?>

    And here is the code from the parent theme I’m trying to change:

    // Parent theme Fluxipress 1.04 excerpt
    
    function fluxipress_add_stylesheets()
    {
    	wp_register_style(
    		'fluxpiress-css-magnific',
    		get_template_directory_uri() . '/css/magnific-popup.css'
    	);
    	wp_enqueue_style('fluxpiress-css-magnific');
    
    	wp_register_style(
    		'fluxpiress-css-fonts',
    		'http' . ($_SERVER['SERVER_PORT'] == 443 ? 's' : '') . '://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,700italic,400,700,300'
    	);
    	wp_enqueue_style('fluxpiress-css-fonts');
    }
    add_action('wp_enqueue_scripts', 'fluxipress_add_stylesheets');

    Note that “fluxipress” is misspelled in the parent theme – “fluxpiress”. Therefor I uesd the same spelling in the child theme.

    Moderator Andrew Nevins

    @anevins

    Forum moderator

    What’s in your style.css file?

    /* Style excerpt */
    
    @import url("../fluxipress/style.css");
    
    body, #commentform #submit, input[type=text], textarea {
    	font-family: 'PT Sans', sans-serif;
    }

    Haven’t got around to style PT Sans Narrow yet…

    Theme Author Michael Kloepzig

    @michael-kloepzig

    Just a heads-up: The misspelling of “fluxipress” will be fixed in 1.0.5 – you’ll have to change it in your child theme accordingly.

    Michael, can you tell me what I need to do to make this child theme work!? You mentioned there is a spelling mistake of ‘fluxipress’ and i need to change my child theme accordingly..do I just have to change the template name in style.css to:

    Template: fluxpiress

    ???
    I used the find and replace tool in dreamweaver to find ‘fluxpiress’ in parent folder (fluxipress) and it found 8 instances of it in functions.php. I replaced ‘fluxpiress’ with ‘fluxipress’ saved it then uploaded it to my server and it is still not reading my child style.css! ahhhhhh!

    Help please. Thank you

    Theme Author Michael Kloepzig

    @michael-kloepzig

    As I said in the other thread, the typos are unlikely to affect your child theme. Please send a zip with your child theme so i can investigate what causes the problems.

    Thanks, have sent you a link to my child theme in other thread.

    WPyogi

    @wpyogi

    Forum Moderator

    Closing this thread – please don’t post in other people’s threads or post the same question in more than one place – it causes much confusion for people helping out here.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘[Resolved] How to change font using a child theme?’ is closed to new replies.