WP-Instagram-Import
Import Instagram posts into WordPress
Configuration
Image uploading requires installing the following WordPress plugin for API authentication: https://github.com/WP-API/Basic-Auth The following WordPress plugin is also recommended for creating application-specific passwords: https://wordpress.org/plugins/application-passwords/
Open the Python script and set your credentials and configuration at the top of the file
- INSTAGRAM_PROFILE: Your Instagram profile username (must be a public profile)
- WORDPRESS_URL: The URL to your WordPress site
- WORDPRESS_USER: The WordPress username that will be creating the posts
- WORDPRESS_PASS: Password for the WordPress account (create an application password above for security)
- WORDPRESS_CATEGORY: The category that will be used for the posts (must already exist)
- DOWNLOAD_PATH: Temporary location for storing images/videos during upload
You may also want to customize the title / content values on lines 73 and 74. By default, the Instagram caption will be used as the title and the post content will contain shortcodes to display a gallery of photos and videos
Optional: Install https://wordpress.org/plugins/rest-api-meta-support to allow storing Instagram URLs in the post metadata for future reference
Usage
Check your Python version and make sure version 3.7 or newer is installed on your system:
$ python3 --version
Install required python3 modules:
$ pip3 install requests instaloader wordpress-api awesome-slugify
Run the Python script from the terminal and it will import any photos or videos from Instagram that are more recent than the last post in the WORDPRESS_CATEGORY
Alternative Version using WP-CLI
An alternative version of this script is available as wp-instagram-import-cli.py
that uses the local WordPress CLI instead of the REST API.
License
Copyright (C) 2022 Sam Steele. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.