How To Add Adsense To Thesis Theme
Justice Erickson![](/file/f035c7f3a6a2bccd2bf48.jpg)
To add AdSense to the Thesis theme, follow these steps:
- Sign in to your AdSense account and navigate to the "Ads" tab.
- Click on the "+ New Ad Unit" button to create a new ad unit.
- Fill in the necessary details such as ad type, ad size, and ad style. Customize the options according to your preference.
- Once you have configured the ad unit, click on the "Save and get code" button.
- Copy the generated ad code.
Now, let's move on to integrating the AdSense code into the Thesis theme:
- Log in to your WordPress dashboard.
- Go to the "Appearance" section and click on "Editor."
- In the right-hand panel, locate and click on "Thesis Theme Custom File Editor."
- In the Custom File Editor, click on "custom_functions.php" to open the file.
- Scroll down to the end of the file and add the following code:
```php function addadsensecode() { echo '
' . get
adsensecode() . ''; }
function getadsensecode() { $adcode = ''; return $adcode; }
addaction('thesishookbeforecontent', 'addadsensecode'); ```
- Replace
<!-- Paste your AdSense code here -->
with the AdSense code you copied earlier. - Click on the "Save" button to save the changes.
The above code adds a new function add_adsense_code()
that echoes the AdSense code within a <div>
element with a class of "ad-container." The get_adsense_code()
function returns the AdSense code, allowing you to easily modify it if needed.
Finally, the add_action()
function hooks the add_adsense_code()
function to the "thesishookbefore_content" action, ensuring that the AdSense code is displayed before the content on each page.
After saving the changes, the AdSense code should now be added to the Thesis theme. Visit your website to verify that the ads are displaying correctly.
Professional Academic Writing Service 👈
![](/file/942a24bc7bb2581332de5.jpg)
Check our previous article: Graduate School How To Write a Thesis