For the complete documentation index, see llms.txt. This page is also available as Markdown.

CSV Import

CSV Import

Rather than manually add shortcodes to your shortcode collection, Snippet Shortcodes has CSV import and export tools which allow you to bulk manage shortcodes.

Note: Depending on your server, you may need to split larger CSV files into smaller, more manageable sizes for performance reasons. As a guide, we'd recommend processing no more than 500 rows at a time.

CSV Format

A CSV file must have a header row with at least these four columns:

slug,content,global,enabled

Note: The column "content" is required however, the data for each row can be left blank if not required.

  • Have one or more data rows.

  • For each row, ensure the following are met:

    • Has a "slug" that is 100 characters or less.

    • Ideally have a value for "content" - otherwise you're importing a blank column.

    • A value of "yes", "no", "true" or "false" for "global".

    • A value of "yes", "no", "true" or "false" for "enabled".

Note: If the import finds the above rules haven't been met, then the row will either be skipped or fail.

Optional columns

If you're on Premium, the CSV format also supports these additional columns. Any of them can be left out of the header row entirely - a shortcode simply gets the same default it would if you left the equivalent option untouched on the edit screen (visible everywhere, no schedule, no page restriction, etc.).

Column
Format
Corresponds to

header

yes / no

Auto-insert into header

footer

yes / no

Auto-insert into footer

target_pages

comma-separated page slugs, blank = every page

Limit header/footer insertion to specific pages

device_type

comma-separated, any of desktop, mobile, tablet; blank = all three

Limit to device types

roles

comma-separated WordPress role slugs and/or guest, blank = everyone

Limit to user roles

visibility_start

YYYY-MM-DD HH:MM:SS, blank = no start limit

Schedule visibility

visibility_end

YYYY-MM-DD HH:MM:SS, blank = no end limit

Schedule visibility

A simple CSV example

An example including the optional Premium columns

Below is a sample CSV with 40 shortcodes:

Importing a CSV file

  • Via the WordPress Admin menu, navigate to "Snippet Shortcodes" > "Import Shortcodes".

  • Using the button labelled "Select CSV", choose a CSV file already uploaded into your Media Library or upload a new one from your computer.

  • Examine the output report and action any errors.

Dry run mode

If selected, dry run mode will run basic tests against each row without attempting to update the database. We recommend you do this before performing an import as it gives the opportunity to correct any issues before attempting the main import.

Exporting a CSV file

Via the WordPress Admin menu, navigate to "Snippet Shortcodes" > "Import Shortcodes", then click "Export CSV" under the "Export CSV" section. This downloads all of your shortcodes as a CSV file, covering every column above, in the same format used for import - handy for backing up your collection, or as a starting point for a bulk edit-then-reimport.

Last updated