Previously I have been able to position GoogleAds within the content on other websites by inserting the code in the correct place in the file single.php or page.php.
However the single.php file in Sparkling is very short and it is not possible to position an ad in the correct place.
Please advise how this issue can be resolved.
I hope you are doing well today.
You can try using the following plugin to add the Google ads to the theme:
another option is to use the widget for the GoogleAds.
The plugin works well and the ads appear within the post after the second paragraph.
Ideally I would like the ad to be at the beginning of the post before the first paragraph and with the text then wrapping around the ad.
How can this be achieved?
Just use the shortcode provided by that plugin in the appropriate place of post.
I have taken a look at the single.php and page.php files but have not found the position in the files to place the shortcode.
The ad should appear at the top of the post content but just below the title? i.e. At the top of the first paragraph.
Where exactly in the code should I add the shortcode?
If you want to display it in the post content then you can add it on line number 47 in the Sparkling child theme file /sparkling/template-parts/content-single.php before the following code.
<?php the_content(); ?>
If you want to display it in the page content then you can add it on line number 27 in the Sparkling child theme file /sparkling/template-parts/content-page.php before the following code.
I must be doing something wrong because I cannot get it to work.
If I send you the FTP credentials could you make the change for me?
Please send me your email address.
The mistake I was making was to make the changes to a copy of content-single.php in the sparkling-child theme folder. After making the changes to a copy of content-single.php in the sub-folder wp-content/themes/sparkling-child/template-parts/, the issue was resolved.
The Adsense Ads are now positioned perfectly at the top of the post content but just below the title? i.e. At the top of the first paragraph.
Thanks for your great support.
You are most welcome here