WPCode Logo

WPCode Documentation

Documentation, Reference Materials, and Tutorials for WPCode

Most Popular

Get free tips and resources right in your inbox, along with 500+ others

Follow Us

File Editor

Would you like to update your site’s ads.txt or robots.txt file without opening an FTP client? The WPCode File Editor manages all four supported files from your WordPress dashboard.

In this guide, we’ll walk you through editing each of the four files and saving your changes.

Requirements: The File Editor is part of the paid version of WPCode and is available with a basic license level or higher.

Before you get started, make sure WPCode is installed and activated on your WordPress site.

Choosing the Right File

The File Editor covers four files, and each one has its own job. Knowing which is which makes picking the right tab straightforward.

ads.txt is short for Authorized Digital Sellers. It lists the companies allowed to sell advertising space on your site. Advertising platforms such as Google AdSense usually hand you the exact lines to paste in.

app-ads.txt does the same job for a mobile app. It names the companies authorized to sell advertising inside your app, and it follows the same formatting rules as ads.txt.

service-worker.js holds JavaScript that browsers run in the background on secure sites. On WordPress sites the most common use is a one-step push notification signup, so visitors can subscribe without being sent to a separate service.

robots.txt tells search engine crawlers which parts of your site to visit. WordPress already generates one from the options in Settings » Reading, and many SEO plugins add to it. WPCode appends your content to what those produce rather than replacing it.

Note: WPCode stores your content and serves each file when a browser or crawler asks for it, so nothing new appears in your site’s folders. That’s the same way WordPress produces a robots.txt file for a site that has no physical copy of one.

Getting Around the File Editor

To get started, we’ll open the File Editor and get familiar with its layout.

From your WordPress admin sidebar, go to Code Snippets » File Editor.

The File Editor screen with the Code Snippets menu shown in the sidebar and File Editor highlighted

Across the top of the page there’s a tab for each supported file: ads.txt, app-ads.txt, service-worker.js, and robots.txt.

Every tab shares the same layout underneath. There’s a heading naming the file, with an Enable file output toggle on the right. Underneath those sit the editor for your contents and a pair of buttons at the bottom.

The File Editor showing the four file tabs, the ads.txt Editor heading, and the Enable file output toggle

With that layout in mind, you’re ready to start on the first tab.

Editing the ads.txt File

The page opens on the ads.txt tab, so there’s nothing to select before you start.

On the right of the editor heading, check that Enable file output is switched on. This is what tells WPCode to serve the file to visitors and crawlers.

An arrow pointing at the Enable file output toggle, switched on beside the ads.txt Editor heading

Next, add your file contents to the editor. Lines beginning with a hash are treated as comments. Each seller line lists the ad system’s domain, your publisher account ID, and whether the relationship is DIRECT or RESELLER.

The ads.txt editor with a comment line, two seller lines, and a contact line

The last line in that example is a contact line. WPCode treats a line written as a name followed by an equals sign as a setting rather than a seller line. That means it accepts the line as written.

When your contents are ready, click Save Changes at the bottom of the editor.

An arrow pointing at the Save Changes button at the bottom of the ads.txt editor

WPCode reloads the page and confirms with a “File saved successfully” message above the editor.

The File saved successfully confirmation message above the ads.txt editor

Your ads.txt content is now saved. Next, it’s worth confirming how the file looks to visitors and crawlers.

Viewing the File on Your Site

Checking the saved file in your browser confirms that WPCode is serving exactly what you entered.

Beside the save button, click View File to open the file exactly as visitors and crawlers receive it.

An arrow pointing at the View File button beside Save Changes at the bottom of the ads.txt editor

It opens in a new tab at your site’s root address, showing the contents you saved as plain text.

The generated ads.txt file served as plain text at the root of the site

With ads.txt in place, the same routine covers the other three files.

Editing the app-ads.txt File

To manage a mobile app’s authorized sellers, select the app-ads.txt tab. Everything on it works the way it does on the ads.txt tab. It uses the same line formatting, the same Enable file output toggle, and the same pair of buttons at the bottom.

An arrow pointing at the app-ads.txt tab, with its editor below holding a comment line and a seller line

Your app’s authorized sellers are now handled from the same page as your site’s.

Editing the service-worker.js File

Background JavaScript for your site lives on its own tab in the File Editor.

To add that code, select the service-worker.js tab.

Because this tab holds JavaScript, the editor colors the code as you type. That makes it easier to spot a missing bracket or quotation mark.

An arrow pointing at the service-worker.js tab, with its editor below showing JavaScript syntax highlighting on two event listeners

Any JavaScript you add here is saved the same way, using the buttons at the bottom of the editor.

Editing the robots.txt File

The robots.txt tab holds the crawler directives you want to add to your site.

To add them, select the robots.txt tab.

A note underneath the editor explains how WPCode handles them. Your content is appended to the robots.txt that WordPress and your other plugins already generate, so anything they produce stays in place.

An arrow pointing at the robots.txt tab, with its editor below holding three directives and the note explaining that content is appended

See How to Optimize Your WordPress Robots.txt for SEO for guidance on which directives are worth adding.

Your directives are saved with the Save Changes button at the bottom of the editor. Beside it, View File opens your site’s robots.txt so you can confirm your directives are there.

Your crawler directives now sit alongside the ones WordPress and your other plugins already produce.

Reading the Validation Messages

WPCode checks the formatting of your ads.txt, app-ads.txt, and robots.txt content each time you save. If a line doesn’t match the expected format, WPCode saves your content and displays a message naming the line and what it found. From there, adjust the line and save again.

A validation message naming line two and the unexpected value, shown above the saved confirmation

On the service-worker.js tab, the syntax coloring plays that role instead.

That’s it! You now know how to manage your site’s ads.txt, app-ads.txt, service-worker.js, and robots.txt files straight from your WordPress dashboard.

Next, you might like to read our guide on access control, which covers how to choose the user roles allowed to work with WPCode.

Frequently Asked Questions

Below, we’ve answered some of the most common questions about the WPCode File Editor.

Does WPCode create these files on my server?

No. WPCode stores what you enter and serves the file when it’s requested, which is why nothing new appears in your site’s folders.

What if my site already has a physical ads.txt file?

WPCode detects it and displays a message explaining that the file needs to be removed from your server first. That’s because a physical file is served before WordPress loads. Once you remove it, the tab becomes editable and WPCode takes over serving the file.

Does the robots.txt tab replace what WordPress generates?

No. Content you add on that tab is appended to the robots.txt that WordPress and your other plugins generate, so their directives remain.

Will a validation message stop my file from saving?

No. WPCode saves your content and shows the message alongside the save confirmation, leaving the decision about what to change with you.

What does the Enable file output toggle do?

It controls whether WPCode serves the file. Switch it off and WPCode stops publishing it, while your content stays saved on the tab ready for whenever you switch it back on.

Can I let other user roles use the File Editor?

Yes. WPCode’s access controls include a dedicated File Editor permission. That lets a role work with these files without giving it access to the rest of WPCode.

Still stuck? How can we help?

Last Updated on

Get Started Today & Add Your Own Snippets

Future-proof your website with WPCode Snippets and improve the way you manage code across all your websites.