WP Manifestindependent plugin directory
manifest / integrations / sync-wp-posts-to-shopify

Sync Posts to Shopify

Automatically sync WordPress posts to Shopify articles using the Shopify Admin GraphQL API

by Ifox Solutions · github.com/yashrojha/sync-wp-posts-to-shopify · website

★ 1stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/yashrojha/sync-wp-posts-to-shopify/archive/refs/heads/main.zip

Sync Wordpress Posts to Shopify

A WordPress plugin that automatically syncs WordPress blog posts with Shopify articles using the Shopify Admin GraphQL API.

Features

  • 🔄 Automatic Sync: Automatically sync posts when published or updated
  • 🎯 Manual Sync: Option to manually sync individual posts
  • 📊 Sync Logging: Track all sync activities with detailed logs
  • 🔐 Secure: Uses Shopify Admin API with custom app credentials
  • 📝 Meta Information: Syncs post title, content, excerpt, tags, author, featured image, and SEO meta via metafields
  • ✅ Visual Indicators: See sync status directly in the posts list
  • 🛠️ Easy Configuration: Simple settings page with step-by-step instructions

Installation

  1. Download or clone this repository into your WordPress plugins directory:

    cd wp-content/plugins/
    git clone https://github.com/Yash-Ojha/sync-posts-to-shopify sync-posts-to-shopify
  2. Activate the plugin through the 'Plugins' menu in WordPress

  3. Go to Settings → Sync to Shopify to configure the plugin

Configuration

Step 1: Generate Shopify API Credentials

  1. Log in to your Shopify Admin at your-store.myshopify.com/admin
  2. Navigate to Settings → Apps and sales channels
  3. Click on Develop apps
  4. Click Create an app and give it a name (e.g., "WordPress Sync")
  5. Configure Admin API scopes and enable:
    • read_content - Read access to articles and blogs
    • write_content - Write access to articles and blogs
    • read_metafields - Read metafields (required for SEO metafields)
    • write_metafields - Write metafields (required for SEO metafields)
  6. Click Save
  7. Go to the API credentials tab and click Install app
  8. Copy your Client ID and Client secret (click to reveal):
    • Client ID: This is visible on the API credentials page
    • Client secret: Click to reveal and copy (save it securely!)

Step 2: Get Your Blog ID

  1. In Shopify Admin, go to Online Store → Blog posts → Manage blogs
  2. Click on your blog name
  3. Look at the URL in your browser: .../admin/blogs/BLOG_ID
  4. Copy the numeric Blog ID (e.g., if the URL shows 123456789, that's your Blog ID)

Step 3: Configure the Plugin

  1. In WordPress, go to Settings → Sync to Shopify
  2. Enter your:
    • Shopify Store URL: your-store.myshopify.com (without https://)
    • Client ID: From Step 1
    • Client Secret: From Step 1
    • Shopify Blog ID: The numeric ID from Step 2
  3. Choose your sync options:
    • ✅ Sync on Publish: Automatically create Shopify articles when posts are published
    • ✅ Sync on Update: Automatically update Shopify articles when posts are updated
  4. Click Save Settings

Note: The plugin uses OAuth 2.0 Client Credentials flow. Access tokens are automatically generated and refreshed every 24 hours. You only need to provide your credentials once.

Usage

Automatic Sync

Once configured, the plugin will automatically:

  • Create a new Shopify article when you publish a WordPress post
  • Update the Shopify article when you update a WordPress post
  • Delete the Shopify article when you delete a WordPress post (if enabled)

Manual Sync

You can manually sync a post at any time:

  1. From the post editor: Look for the "Shopify Sync Status" meta box on the right sidebar and click "Sync to Shopify Now"
  2. From the publish box: Click the "Sync Now" button in the publish meta box
  3. Bulk sync: Coming in a future update!

Sync Status

  • Green checkmark (✓): Post is synced with Shopify
  • Gray circle (○): Post has not been synced yet

View Sync Logs

Go to Settings → Sync to Shopify and scroll down to see the "Recent Sync Activity" table showing:

  • Date and time of sync
  • Post title
  • Action performed (create/update/delete)
  • Status (success/error)
  • Detailed message

What Gets Synced?

The plugin syncs the following information from WordPress to Shopify:

  • Title: Post title
  • Content: Full post content (HTML formatted)
  • Excerpt: Post excerpt (if available)
  • URL Slug: Post slug/permalink (handle)
  • Author: WordPress author name (on creation only)
  • Tags: Post tags
  • Featured Image: Post thumbnail/featured image
  • Publish Date: WordPress publish date is synced to Shopify published_at

Note:

  • Shopify automatically sets the published date to the current time when creating articles
  • This plugin overrides that by syncing your WordPress publish date to Shopify after create/update
  • The author field is required during creation (sent as an AuthorInput object with a name property) but cannot be updated later
  • If the WordPress author's display name is empty, it falls back to username, then to "WordPress"
  • SEO meta title/description: Synced via Shopify metafields:
    • global.title_tag (meta title)
    • global.description_tag (meta description) The values are taken from Yoast/Rank Math/AIOSEO if set; otherwise fall back to post title + site name and excerpt/content.

Technical Details

Authentication

The plugin implements Shopify's OAuth 2.0 Client Credentials flow:

  • Access tokens are generated on-demand using your Client ID and Client Secret
  • Tokens are cached for 23 hours using WordPress transients
  • Tokens are automatically refreshed before expiry
  • If credentials change, the cached token is immediately cleared

WordPress Hooks Used

  • publish_post - Triggers sync when a post is published
  • post_updated - Triggers sync when a post is updated
  • before_delete_post - Triggers sync when a post is deleted

Shopify GraphQL API

The plugin uses the following GraphQL mutations:

  • articleCreate - Create new articles
  • articleUpdate - Update existing articles
  • articleDelete - Delete articles

Database

The plugin creates a custom table wp_spts_sync_log to store sync logs.

Post Meta

Synced posts have the following meta key:

  • _shopify_article_id - Stores the Shopify article ID (GID format)

Filters & Hooks

Developers can extend the plugin using these filters:

// Modify article data before sending to Shopify
add_filter('spts_shopify_article_data', function($data, $post, $is_update) {
    // Modify $data array
    return $data;
}, 10, 3);

Troubleshooting

Sync Fails with "API Error"

  • Verify your Shopify store URL is correct (without https://)
  • Check that your Client ID and Client Secret are correct
  • Ensure your app has the correct API scopes (read_content, write_content, read_metafields, write_metafields)
  • The plugin automatically handles access token generation and refresh

Article Not Appearing in Shopify

  • Check that your Blog ID is correct
  • Verify the post is published (not draft)
  • Check the sync logs for error messages

SEO Meta Title/Description

Important: Shopify's GraphQL API does NOT provide direct SEO fields for blog articles. Custom meta titles and descriptions for articles can only be set via metafields (complex implementation not included in this plugin).

Current Behavior:

  • Shopify automatically generates SEO metadata from your article's title and content
  • The article title becomes the meta title
  • The beginning of the article content becomes the meta description
  • This is Shopify's standard behavior for blog articles

Workaround: If you need custom SEO, you can manually edit the article's SEO in Shopify Admin after syncing from WordPress.

Connection Issues

  • Ensure your WordPress site can make outbound HTTPS requests
  • Check that your hosting doesn't block Shopify's API endpoints
  • Access tokens are cached for 23 hours and automatically refreshed
  • Check the settings page to see if an access token is currently active

Requirements

  • WordPress 5.0 or higher
  • PHP 7.4 or higher
  • Active Shopify store with custom app access
  • WordPress posts must be publicly published

Support

For issues, questions, or feature requests, please open an issue on GitHub or contact support.

License

GPL v2 or later

Credits

Developed by Yash Ojha (Ifox Solutions)

Changelog

Version 1.0.5

  • Added "Append Original Link" feature with enable/disable setting
  • Added position option (top/bottom) for original link placement
  • Added "Keep Original Canonical URL" setting to sync canonical URL metafield
  • Added instructions for creating canonical URL metafield in Shopify
  • Improved uninstall script to preserve post meta (prevents duplicates on reinstall)
  • Enhanced sync logic to handle existing articles by handle/title
  • Automatic sync on publish and update
  • Manual sync option
  • Sync logging and status tracking
  • Settings page with API configuration
  • Shopify API key generation instructions