• Hello,

    I created a child theme with the use of a plugin. I need to add some code to the header.php file, but the child theme does not have this file. So, I would like to create this file on the child theme. I do not know code and haven’t used ftp.

    I have two questions:

    1) I was wondering if there was a way to create this file in WordPress.

    Also, I have GoDaddy hosting and when I go to the “Files and Ftp” section I can see the child theme and the files that are currently there. There is a button along the top that says “upload” and another that says “new”. So, I am not sure if either of these would allow me to do what I need to do.

    2) Where do I enter code in the header.php file to make something appear at the top right hand corner of the site? I added it before the closing </head> tag but this placed the dropdown at the bottom right hand corner of the site.

    Any help is much appreciated 🙂

    Thank you so much!

    Have a great day!

    Michelle

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hello Michelle. You can copy the header.php file from the parent theme’s folder to the child theme’s folder. Most likely the “Files % FTP” section of your hosting panel will also have a copy/paste functionality.
    Once the file is copied to the child theme, you will need to edit it and paste your code in. Unfortunately there is no absolute place you can put the code in so it appears in the top right hand corner.
    An option is to put your code in a new div, for example like this

    <div class="my-code"> Your code here </div>

    place the div just below the <body> tag and add this

    .my-code {position: absolute; top: 0; right: 0;}

    in your theme’s custom CSS box (if it has one) or at the bottom of the child’s style.css file, this should place the code in the top right corner of the site.

    Thread Starter MSweet123

    (@msweet123)

    @nvourva…Thank you! Thank you! Thank you!

    That worked beautifully! I just had to edit the top margin a little.

    One more question please, if you have time:

    I have a site using the Superb Lite theme. It only allows for 2 slider images on the front page. How can I edit the code to allow for 3 more images? This is what the code for the slider looks like:

    <div class=”slider-wrapper clearfix”>
    <div class=”flexslider”>
    <ul class=”slides”>
    <?php
    // check if the slider is blank.
    // if there are no slides by user then load default slides.
    if ( get_theme_mod(‘slider_one’) ==” ) { ?>
    <li id=”slider1″>
    <img src=”<?php echo get_template_directory_uri(); ?>/assets/images/slide1.jpg” alt=””/>
    <div class=”flex-caption”>
    <div class=”caption-content”>
    <div class=”caption-inner”>
    <h2 class=”slider-title”><?php esc_html_e(‘Perfect for your business website’, ‘superb’) ?></h2>
    <p><?php esc_html_e(‘Superb is a theme designed for your business website.’, ‘superb’) ?> </p>

    <?php esc_html_e(‘Start Building Your Website Now’, ‘superb’) ?>

    </div>
    </div>
    </div>

    <li id=”slider2″>
    <img src=”<?php echo get_template_directory_uri(); ?>/assets/images/slide3.jpg” alt=””/>
    <div class=”flex-caption”>
    <div class=”caption-content”>
    <div class=”caption-inner”>
    <h2 class=”slider-title”><?php esc_html_e(‘Showcase your work and services’, ‘superb’) ?></h2>
    <p><?php esc_html_e(‘Use the home featured section to showcase your services.’, ‘superb’) ?> </p>

    </div>
    </div>
    </div>

    <?php } ?>

    <?php
    // if user adds a cusotm slide then display the slides
    // load first slide
    if ( get_theme_mod(‘slider_one’) !=” ) { ?>
    <li id=”slider1″>
    <img src=”<?php echo esc_url(get_theme_mod(‘slider_one’)); ?>” alt=””/>
    <?php if ( get_theme_mod(‘slider_title_one’) !=” || get_theme_mod(‘slider_one_description’) !=” ) { ?>
    <div class=”flex-caption”>
    <div class=”caption-content”>
    <div class=”caption-inner”>
    <h2 class=”slider-title”><?php echo esc_html(get_theme_mod(‘slider_title_one’)); ?></h2>
    <p><?php echo esc_html(get_theme_mod(‘slider_one_description’)); ?></p>

    <?php if ( get_theme_mod(‘slider_one_link_url’) !=” && get_theme_mod(‘slider_one_link_text’) !=” ) { ?>
    “>
    <?php echo esc_html(get_theme_mod(‘slider_one_link_text’)); ?>
    <?php } ?>

    </div>
    </div>
    </div>
    <?php } ?>

    <?php
    // load second slide
    if ( get_theme_mod(‘slider_two’) !=” ) { ?>
    <li id=”slider2″>
    <img src=”<?php echo esc_url(get_theme_mod(‘slider_two’)); ?>” alt=””/>
    <?php if ( get_theme_mod(‘slider_title_two’) !=” || get_theme_mod(‘slider_two_description’) !=” ) { ?>
    <div class=”flex-caption”>
    <div class=”caption-content”>
    <div class=”caption-inner”>
    <h2 class=”slider-title”><?php echo esc_html(get_theme_mod(‘slider_title_two’)); ?></h2>
    <p><?php echo esc_html(get_theme_mod(‘slider_two_description’)); ?></p>

    <?php if ( get_theme_mod(‘slider_two_link_url’) !=” && get_theme_mod(‘slider_two_link_text’) !=” ) { ?>
    “>
    <?php echo esc_html(get_theme_mod(‘slider_two_link_text’)); ?>
    <?php } ?>

    </div>
    </div>
    </div>
    <?php } ?>

    <?php } ?>

    <?php } ?>

    </div>
    </div>

    Thank you!

    Michelle

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Create header.php file for child theme’ is closed to new replies.