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

Using the WPCode File editor you can easily manage common website configuration files directly from the WordPress dashboard without having to use FTP or other tools.

Currently, the WPCode plugin supports editing the following files:

  • ads.txt
  • app-ads.txt
  • service-worker.js
  • robots.txt

By default, if the file contents are empty, WPCode will not output any replacement of the file. You can also toggle each file output individually if you want to quickly disable the file output without having to edit the file contents.

This functionality does not create an actual file on your server and instead loads the file contents from your settings in a similar way to how WordPress generates the default robots.txt file. This means that if you have a physical file on your server for any of these files you will not be able to edit it or replace its contents inside WPCode as in most setups the physical file will take priority when loading.

If you have a physical file on your server for any of the files supported by the WPCode file editor you will need to first remove the file from your server before you can manage it with WPCode.

File types

Each file supported by the WPCode File Editor has a specific purpose which we’ll outline below:

ads.txt

The ads.txt file is short for for ‘Authorized Digital Seller.’ It was developed by the IAB Tech Lab to help prevent fraud in advertising on websites. This file is used to list all the companies that are allowed to sell advertising space on your website. The contents of this file are usually provided by the advertising platform if you are using an advertising platform like Google Adsense.

app-ads.txt

App-ads.txt is similar to the ads.txt file you can host on your site if you have a mobile app and similar to the ads.txt file it indicates companies that are authorised to advertise in your mobile app.

service-worker.js

The service-worker.js file is used by browsers to handle special instructions on https websites, the most common use in a WordPress site is to set up 1 step Push Notifications subscribe to avoid going through a vendor. You can set up push notifications for your site with a service like PushEngage.

robots.txt

As the name suggests, the robots.txt file is meant to be processed by “robots” visiting your site. The most common type of robot visiting your site is a crawler from a search engine like Google. WordPress, by default, generates a robots.txt file for your site based on your Reading settings and it either encourages or discourages search engines from indexing your site. Most SEO plugins also manage the robots.txt file for improvements and WPCode only allows you to append the robots.txt file if you need that, so the content you add in the WPCode file editor will be appended to the robots.txt file generated by WordPress and other plugins. This can be useful for quickly making an adjustment without having to install an extra plugin.

Error validation

The WPCode file editor includes syntax validation for each type of snippet. While a syntax error will not prevent you from saving the changes you make to a file, they will be displayed to warn you about them and give you a chance to adjust. This gives you full control but also attempts to help you spot typos or other common errors when formatting the files.

The service-worker.js has syntax checks directly in the editor since you can use JavaScript code but the other, txt files, benefit from validation specific to the file format and errors are displayed after the file is saved.

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.