How to Import WordPress Attachments onto a Post Type
Attachments can be imported on WordPress Pages, Posts, Custom post types, and all templates using these as a base. Attachments can be fetched from within a local directory, remote url, or from a ftp server.
Importing an Attachment
To add a new attachment click on the Add Row button at the bottom of the attachments panel, this will insert a new row.
Options | Description |
---|---|
Location | The location field should be the source of the file or files that you want to attach, to import multiple files you can enter a comma separated list of attachment sources. The location field is used for all download types (ftp, local filesystem, remote url). |
Is Featured? | The is featured field allows you to set the featured image on the first attachment imported. |
Download | The download field sets how the attachments should be imported (ftp, local filesystem, remote url). |
Import attachments via FTP
To import attachments via FTP set the download option to FTP, this will enable an extra set of fields to configure the FTP connection.
Options | Description |
---|---|
Host | The ftp host |
Username | The ftp username |
Password | The ftp password |
Path | The path is an optional field, this filed will prefix each attachment source set in the location field. |
Import attachments from the Local Filesystem
To import attachments from the Websites Local Filesystem set the download option to Local Filesystem, this will enable an extra field allowing you to set the base path to the attachment files on the local filesystem.
Options | Description |
---|---|
Base URL | The base URL is an optional field, this filed will prefix each attachment source set in the location field. |
Import attachments from a Remote Url
To import attachments from the Remote Url set the download option to Remote Url, this will enable an extra field allowing you to set the base url to the attachment files on the remote server.
Options | Description |
---|---|
Base URL | The base URL is an optional field, this filed will prefix each attachment source set in the location field. |
Importing exiting attachments from media library
If you do not want to download any new attachments and only use existing attachments already added to your media library, set the download field to “Media library”, then setting the location field to reference an image filename or filename path.
Enable Meta
This enable meta field enables extra field to populate attachment meta data:
Options | Description |
---|---|
Alt Text | Set the attachments alt text. |
Title Text | Set the attachments title text. |
Caption Text | Set the attachments caption text. |
Description Text | Set the attachments description. |
How to change the attachment value delimiter / seperator
By default entering multiple images in the location field seperated by a comma will import multiple images.
You can change the attachment delimiter / seperator by using the following code
add_filter('iwp/attachment/value_delimiter', function($delimiter){
return ','; // change the , to any character e.g. | ; or #
});