How To Add Adsense To Thesis Theme

How To Add Adsense To Thesis Theme

Justice Erickson
How To Add Adsense To Thesis Theme

To add AdSense to the Thesis theme, follow these steps:

  1. Sign in to your AdSense account and navigate to the "Ads" tab.
  2. Click on the "+ New Ad Unit" button to create a new ad unit.
  3. Fill in the necessary details such as ad type, ad size, and ad style. Customize the options according to your preference.
  4. Once you have configured the ad unit, click on the "Save and get code" button.
  5. Copy the generated ad code.

Now, let's move on to integrating the AdSense code into the Thesis theme:

  1. Log in to your WordPress dashboard.
  2. Go to the "Appearance" section and click on "Editor."
  3. In the right-hand panel, locate and click on "Thesis Theme Custom File Editor."
  4. In the Custom File Editor, click on "custom_functions.php" to open the file.
  5. 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'); ```

  1. Replace <!-- Paste your AdSense code here --> with the AdSense code you copied earlier.
  2. 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 👈

Graduate School How To Write a Thesis

Check our previous article: Graduate School How To Write a Thesis

Report Page