• Is there a way to change header.php in a child theme to add <body class=”home twentyseventeen-front-page”> to every page so that the video in the header shows on every page? Or is there another way to add video in the header on every page?

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi, you need to filter the is_header_video_active function in your child theme’s functions.php file

    function cyberium_video_header_pages( $active ) {
        if ( is_page() || is_single() ) {
            return true;
        }
    
        return false;
    }
    
    add_filter( 'is_header_video_active', 'cyberium_video_header_pages' );
    Thread Starter cyberium

    (@cyberium)

    Hi Jarret

    Thanks. I tried that and it hasn’t worked I’m afraid. See: https://bdcr.org.uk/about/

    Any other ideas? Here are the full contents of functions.php:

    <?php

    /**
    * Twenty Seventeen Child Theme functions
    *
    * @link https://developer.www.ads-software.com/themes/basics/theme-functions/
    *
    * @package WordPress
    * @subpackage Twenty_Seventeen
    * @since 1.0
    * Change the minimum screen size to use the video header
    */

    function cyberium_video_header_pages( $active ) {
    if ( is_page() || is_single() ) {
    return true;
    }

    return false;
    }

    add_filter( ‘is_header_video_active’, ‘cyberium_video_header_pages’ );

    add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_styles’ );

    function my_theme_enqueue_styles() {
    $parent_style = ‘twentyseventeen-style’; // This is ‘twentyseventeen-style’ for the Twenty seventeen theme.
    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),
    wp_get_theme()->get(‘Version’)
    );
    }

    Hmm, do you have any other customizations done to the theme? I used the code I provided on a default install of TwentySeventeen and it shows the video I setup across multiple pages.

    Thread Starter cyberium

    (@cyberium)

    Sorry I missed this answer. All the customisations are in the box above, except for some CSS that changes the colour of the site title and description. Can you send a link to your site please? Which version of WordPress are you using?

    Thread Starter cyberium

    (@cyberium)

    @jarretc – are you sure you didn’t add anything else on your site to make it work, like defining the functions you cite?

    Hi, I was just using a default install of TwentySeventeen on my local PC and had just added that code directly at the bottom of the functions.php file and it was working for me. Do you have any plugins active that could be conflicting with the code?

    Thread Starter cyberium

    (@cyberium)

    What sort of plug-in might do that? I deactivated the likeliest suspects and it made no difference.
    So instead of putting the code in the child theme’s functions.php I put it in the parent theme’s functions.php and it worked. Magic. I wonder why? Thanks anyway.

    Thread Starter cyberium

    (@cyberium)

    Hi @jarretc – this solution works brilliantly on all pages but the blog page. Any idea how to make it do that please?

    Hi. What does the code look like that you have setup now?

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Video in header’ is closed to new replies.