• Resolved cztaki73

    (@cztaki73)


    Hi all

    i want to add to my Dyad them, front page, below the Main Photo, the code of Google adsense , can you help me?

    i have alredy the plugin, Google Adsense Ads Manager, but only for Posts ……

    thank you

Viewing 15 replies - 1 through 15 (of 22 total)
  • Hi there!

    It is possible to add some code beneath the image on the home page but, please note, that this does require some familiarity with HTML and PHP.

    The first step to is for you to set up a child theme.

    Next, copy the header.php file from the parent theme to your child theme’s directory.

    The following code within that file is what defines the main image/slider on the home page:

    <?php if ( is_home() || is_front_page() || ( is_single() && 'image' == get_post_format() ) ) : ?>
    			<div class="featured-content">
    				<?php get_template_part( 'template-parts/loop', 'banner' ); ?>
    			</div>
        <?php endif; ?>

    You can add your own code just before <?php endif; ?> in order to insert an ad just below the slider on the home page.

    Let me know how you get on with that. If any questions come up along the way, I’ll be happy to offer some guidance. Just let me know.

    Thread Starter cztaki73

    (@cztaki73)

    Hi

    Thank you so much for the reply, but I don’t have the knowledge of this.

    Do you know maybe, how I can get direct support from Dyad theme team?

    Kind regards

    Hi there,

    I work for the company behind this theme (Automattic) and am on the team that provides support for it.

    Although I can offer guidance on how to customise your theme and answer questions on any steps you may get stuck on, we don’t provide full customisation services.

    If you’re not comfortable with digging into the code yourself, then you could consider hiring someone to make customisations on your behalf. You can find the official WordPress jobs board, where you can post a listing for free, here:

    https://jobs.wordpress.net/

    If you change your mind and decide to give it a go yourself, let me know if questions come up.

    Thread Starter cztaki73

    (@cztaki73)

    Hi Siobhan

    i have created the child theme , called, -child,
    -The child theme directory
    -style.css

    but i have stoped to fuctions.php file because of the below message , creating the third required step for the child theme……

    https://codex.www.ads-software.com/Child_Themes

    —–The final step is to enqueue the parent and child theme stylesheets. Note that the previous method was to import the parent theme stylesheet using @import: this is no longer best practice, as it increases the amount of time it takes style sheets to load. The correct method of enqueuing the parent theme stylesheet is to add a wp_enqueue_scripts action and use wp_enqueue_style() in your child theme’s functions.php. You will therefore need to create a functions.php in your child theme directory. The first line of your child theme’s functions.php will be an opening PHP tag (<?php), after which you can enqueue your parent and child theme stylesheets. The following example function will only work if your Parent Theme uses only one main style.css to hold all of the css. If your theme has more than one .css file (eg. ie.css, style.css, main.css) then you will have to make sure to maintain all of the Parent Theme dependencies.——–

    i totaly lost it…… i have a file empty, Fuctions.php, and i dont know and i dont understand , what i have to do……..!

    any help?

    thank you for your time.

    Thread Starter cztaki73

    (@cztaki73)

    and one more thing…….

    to my settings-Themes- i get this message……

    Name Description
    -child Template is missing. Standalone themes need to have a index.php template file. Child themes need to have a Template header in the style.css stylesheet. Delete

    regards

    antony

    Hi Antony,

    i totaly lost it…… i have a file empty, Fuctions.php, and i dont know and i dont understand , what i have to do……..!

    You can copy the code from the codex page for setting up a child theme directly to your child theme’s functions.php file:

    <?php
    add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
    function my_theme_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    
    }
    ?>

    Saving the above will also resolve the error message you’re seeing in your admin area.

    Let me know how that goes!

    Thread Starter cztaki73

    (@cztaki73)

    thank you so much

    now i get a message

    -child the parent theme is missing. Please Install the parent theme “Dyad”.

    and near this a button Install…….

    should i do it ??

    Hi Antony,

    You won’t need to install Dyad again as you already have that theme active.

    I can see that your version of Dyad is stored under a directory named dyad-wpcom. With this in mind, please rename this part of your child theme’s style.css file:

    Template: dyad

    To this:

    Template: dyad-wpcom

    This will make sure your child theme inherits code from the dyad-wpcom directory.

    Thread Starter cztaki73

    (@cztaki73)

    hi

    so now it is fine. Great!!!

    i have already add my code to header.php file, but nothing happens.
    but
    if i go to live preview to child theme i see my Add ( to the left side, i want it to Center), but to my Home page doesnt appears.

    i miss something?……

    thank you for your time.

    Thread Starter cztaki73

    (@cztaki73)

    i am realy sorry…. i avtivate it and it is almost ok…….

    the space is blank but if i right clik-Check the page , i see the Ad…..

    should i do something?

    kind regards

    antony

    Hi Antony,

    Could you try adding the code for your ad straight after the following in your header.php file?

    <div id="content" class="site-content">

    Let me know when you’ve done that and I’ll take another look.

    Thread Starter cztaki73

    (@cztaki73)

    Hi

    i did that, but its the same. but i saw that this add appears on the top right of an Article…… plus the tree Ads that i have already and i removed it from there you told me.

    on mobile the Add appears but ofcourse with desktop size…..

    thank you

    Hi Antony,

    I can see that the ad is there but hidden behind the the featured slider on your home page. We can get around this if you move the code below this part of the file:

    <div id="content" class="site-content">

    After you’ve moved the code, let me know and I can then see if there’s a way to reposition it from there.

    Additionally, can you confirm if you want the ad to only appear on the home page or if you want it on all pages of your site?

    Thread Starter cztaki73

    (@cztaki73)

    Yes of course I will do that.

    I want the Add only in home page, because I use a plug-in for Adsense for posts.

    Now it is there

    Thanks

    Thank you for confirming that you only want the ad on your home page!

    After some further testing, I can see that it’ll be tricky to add the code via header.php due to the way the posts on the home page have been positioned to scroll over the featured content area.

    Instead, we can add the code to index.php. The code that defines the posts on your home page can be found in this file.

    To get started: Remove the code that you added to header.php and then make a copy of the parent theme’s index.php file to your child theme’s directory.

    Enter the code for your ad directly beneath this line in the file:

    <main id="primary" class="content-area" role="main">

    Let me know how that goes!

Viewing 15 replies - 1 through 15 (of 22 total)
  • The topic ‘Google Adsense to home page code installation’ is closed to new replies.