How to Create an ads.txt File in WordPress Without FTP or cPanel

How to Create an ads.txt File in WordPress Without FTP or cPanel featured image

Reading Time: 5 min, 2 sec

If you are running ads on your website, you must have heard about ads.txt. Google and other ad networks often ask publishers to place this file at the root of their domain. It helps prevent unauthorized sellers from misrepresenting your ad inventory. In short, ads.txt protects your revenue and builds trust with advertisers.

The problem is that most guides will tell you to upload the ads.txt file using FTP or cPanel. But what if you do not have access to these? Do not worry. You can still create and manage ads.txt directly from your WordPress dashboard. In this guide, I will explain everything step by step.

Best WordPress Hosting

Bluehost is one of the best and secure WordPress hosting provider

Also see: How to Add Google AdSense to Your WordPress Blog

What is ads.txt?

ads.txt stands for Authorized Digital Sellers. It is simply a text file placed at yourdomain.com/ads.txt. This file contains the details of all ad networks and resellers that are allowed to sell your ad space.

For example, if you use Google AdSense, they will give you a line like this:

google.com, pub-1234567890123456, DIRECT, f08c47fec0942fa0

This line tells advertisers that Google is an authorized seller of your ad inventory. If you are working with multiple ad networks, you just add more lines.

Why do you need ads.txt?

If you are a publisher, ads.txt is not just another technical file. It plays a direct role in protecting your website’s advertising business. Here is why it matters so much:

1. Protection against ad fraud

The digital advertising industry faces a huge problem with ad fraud. Many unauthorized companies try to sell ad space pretending to be genuine publishers. This is called domain spoofing. For example, a fraudster could claim they are selling ad inventory for your site, but in reality, they are not connected to you at all. Advertisers might pay them thinking they are buying space on your site.

With ads.txt, you publish an official list of ad networks and resellers that are authorized to sell your inventory. Advertisers and ad exchanges can check this file before bidding on your ad slots. If your site is not listed, they will know it is fake. This simple step protects you from fraud and ensures that money flows only to you.

2. Transparency for advertisers

Advertisers want to know where their money is going. When they buy ads, they need to be sure that their ads are appearing on the right websites. The ads.txt file makes this process transparent. It tells them exactly which ad exchanges and resellers are officially approved by you.

3. Requirement from ad networks

Most ad networks today, including Google AdSense, Google Ad Manager, and many programmatic ad platforms, require publishers to implement ads.txt. If you do not have it, they may show warnings in your dashboard, or in some cases, they may limit ad serving.

By publishing the file, you are meeting the industry standards set by the IAB Tech Lab (the organization that created ads.txt). Without it, you might even lose eligibility to work with some premium ad networks.

4. Preventing revenue loss

If you do not have ads.txt, you may lose money in two ways:

  • Advertisers might avoid bidding on your site because they cannot confirm who is authorized to sell your ad space.
  • Fraudulent sellers could redirect ad spend away from you by pretending to be your site.

Both situations result in reduced revenue. Even if your traffic is high, the absence of ads.txt can stop you from getting the full value of your ad impressions.

How to create ads.txt in WordPress without FTP or cPanel

Now let us see how you can create the file directly from the WordPress dashboard. There are two methods.

The simplest way is to install a plugin that manages the ads.txt file for you.

Login to your WordPress dashboard and Go to Plugins → Add New. Search for “Ads.txt Manager” plugin. Click Install Now and then Activate. After activation, go to the plugin’s settings page.

create ads.txt in WordPress without FTP or cPanel

Copy the ads.txt lines given by your ad network and paste them into the text box. Save changes.

    Now, open yourdomain.com/ads.txt in your browser. You should see your entries there.

    This method is safe, simple, and works even if you change your theme. That is why I recommend it for most website owners.

    Method 2: Without a plugin (using custom code)

    If you do not want to install another plugin, you can serve the ads.txt file using a small code snippet. Since you do not have FTP or cPanel access, the best way is to use a plugin like Code Snippets to add custom code safely.

    Add this code in the functions.php.

    add_action( 'init', function() {
        if ( isset($_SERVER['REQUEST_URI']) ) {
            $request_uri = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
            if ( $request_uri === '/ads.txt' || $request_uri === '/ads.txt/' ) {
                header( 'Content-Type: text/plain; charset=utf-8' );
                // Replace with your actual ads.txt lines
                echo "google.com, pub-1234567890123456, DIRECT, f08c47fec0942fa0\n";
                echo "example.com, 9876543210, RESELLER\n";
                exit;
            }
        }
    } );
    

    Replace the sample lines with the actual ones from your ad provider.

    If you do not want to directly edit functions.php, you can use Code Snippets plugin to insert this PHP code in your functions.php file.

      Now visit yourdomain.com/ads.txt and check if it works.

      This method gives you more control, but it is slightly technical. If you make a mistake in the code, you might get errors. That is why beginners should stick to the plugin method.

      Wrap Up

      Creating an ads.txt file in WordPress is easy, even if you do not have FTP or cPanel access. With the right plugin, it only takes a few minutes. And if you prefer not to install plugins, you can still do it with a small piece of code.

      The important thing is to copy the ads.txt lines exactly as provided by your ad partners. Once you publish and verify the file, you can relax knowing your ad revenue is safe.

      Deepanker profile image

      Written by Deepanker

      Deepanker Verma is an experienced WordPress developer who has been working on WordPress for more than 12 years. On TheWPGuides, he writes about WordPress, WordPress development, and WordPress plugins.

      Leave a Reply

      Your email address will not be published. Required fields are marked *

      Need a Hand with Your WordPress Site?

      Don't let technical issues slow you down. Our professional WordPress maintenance service handles updates, security, and performance optimization so you can focus on what you do best: creating content.

      Learn More About Our Services