Content MarketingMarketing Tools

WordPress Plugin: DK Post Sync for Google Docs

I publish dealer SEO articles for my employer and have a growing archive, and I want those articles available to Gemini and the Model Context Protocol (MCP) tools we use as a knowledge base we can actually trust. The problem is access. I didn’t want to give an AI assistant, or a connector that sits in front of one, a WordPress login or a path into the site itself since we already utilize Google Docs for this purpose.

The clean answer is a copy of every published post in a shared Google Drive folder those tools can already read. That is why I built DK Post Sync for Google Docs. It keeps one Google Doc for every published post, stays current as I publish, edit, unpublish, and delete, and it never requires the AI tools to touch WordPress. It is free in the WordPress plugin directory, developed by me, and it started as a tool I needed on our site.

Why I Built a Sync Plugin That Keeps AI Tools Off the Site

The more I use Gemini and MCP integrations against our own writing, the more obvious the gap becomes. Those tools are useful when they can see the current version of an article, including the title, live URL, categories, and SEO fields. They are a liability when the only way to give them that view is to open the CMS to them.

A Drive folder is a much better boundary. I can share that folder with a Google account, with Gemini, or with an MCP client, and I can revoke the share without touching WordPress users, roles, or application passwords. The site stays closed. The knowledge base stays current, because the Docs are written from the published posts themselves, not from a manual export I will forget to repeat.

What DK Post Sync for Google Docs Does

The plugin keeps one Google Doc for every published post in a Drive folder you choose, using your own Google Cloud OAuth client. Your Google data goes only between your site and Google. Here is what each Doc includes:

  • A Post Details table: title, URL, post ID, slug, status, published and modified dates, author, categories, tags, excerpt, SEO title, meta description, focus keyword and canonical URL (from Rank Math or Yoast SEO when either is active), the featured image and its alt text, and the word count.
  • The featured image.
  • The post content, rendered the same way your site renders it. Scripts, forms, and styling are removed, and embeds become links.
  • Images in This Post: every image URL with its alt text.
  • An optional HTML header at the top of every Doc, which you can use to give Gemini or an MCP client context and instructions.

Syncing follows the life of the post:

What Happens in WordPressWhat Happens in Drive
A post is publishedA Doc is created, or the existing Doc is restored from the Drive trash
A published post is updated (content, title, tags, categories, featured image, or SEO fields)The Doc’s content is replaced
A post is unpublished, made private, password-protected, or trashedThe Doc is moved to the Drive trash
A post is deleted permanentlyThe Doc is moved to the Drive trash

Saving a post never calls Google directly. The post is added to a queue, and WP-Cron sends the queue to Drive about 20 seconds later, then every 5 minutes. On the Sync tab, Sync All Posts queues everything and works through the queue while the page is open. Posts that have not changed are skipped.

Give AI Tools Context With an Optional Doc Header

A folder of article copies is useful, but a knowledge base works better when each file explains what it is. Version 1.0.1 adds an optional HTML header that is placed at the top of every synced Doc. You can use it to tell Gemini or an MCP client that the file is a copy of a published article, where the live page lives, and how the tool should treat the text.

The field is on Settings, then DK Post Sync, then Settings. Leave it blank if you do not want a header. Allowed tags are the same as in posts. These placeholders are replaced for each post:

PlaceholderWhat It Becomes
{post_title}The post title
{permalink}The live URL of the post
{date}The post’s published date, in the format from Settings, then General

Here is an example header you can paste in and adapt:

<p>This is a synced copy of the published Martech Zone article <strong>{post_title}</strong>. Use it as source material when answering questions about our content. The live page is <a href="{permalink}">{permalink}</a>. Published {date}.</p>

After you change the header, click Sync All Posts on the Sync tab to update Docs that already exist. New and updated posts pick up the current header the next time they sync.

How to Install and Set Up the Plugin

Install the Plugin

The plugin is in the WordPress plugin directory. It requires WordPress 6.1 or higher and PHP 7.4 or higher.

  1. In your WordPress dashboard, open Plugins, then Add New, and search for DK Post Sync for Google Docs. You can also download it from WordPress.org and upload the dk-post-sync-for-google-docs folder to /wp-content/plugins/.
  2. Select Install Now, then Activate.
  3. Go to Settings, then DK Post Sync, then Google Connection, and copy the Authorized redirect URI. It looks like https://example.com/wp-admin/admin-post.php?action=dknm_gdocs_oauth.

Your site must use HTTPS, because Google accepts plain http redirect URIs only for localhost.

Set Up Your Google OAuth Client

The plugin uses your own Google Cloud OAuth client, so there is no third-party service in the middle. Until an administrator saves a client and connects a Google account, a notice on the plugin screen and on the Plugins screen links to the setup tab, every sync control stays disabled, and the server refuses every sync request. Nothing is queued or sent to Google.

  1. Open the Google Cloud Console and create a project, or pick an existing one.
  2. Enable the Google Drive API for the project (APIs and Services, Library, Google Drive API, Enable).
  3. Configure the OAuth consent screen (Google Auth Platform, Branding and Audience). Choose Internal if you use Google Workspace and only people in your organization will connect. Otherwise choose External and add your Google account as a test user.
  4. Under Data Access, add the scope https://www.googleapis.com/auth/drive.file, or https://www.googleapis.com/auth/drive if you choose full Drive access.
  5. Under Clients, click Create client, choose Web application, add the redirect URI you copied under Authorized redirect URIs, and click Create.
  6. Copy the Client ID and Client secret.
The Google Connection tab in DK Post Sync for Google Docs, showing the redirect URI, OAuth client fields, Drive access options, and Google Cloud setup steps
The Google Connection tab, with the redirect URI, client fields, and setup steps.

Connect, Create a Folder, and Sync

  1. On the Google Connection tab, paste the client ID and secret and click Save Google Settings.
  2. Click Connect with Google, sign in, and allow access. The tab then shows the connected account’s email address and the connection status.
  3. On the Settings tab, click Create Folder in Google Drive, or paste an existing folder’s link if you chose full Drive access.
  4. On the Sync tab, click Sync All Posts.
The Sync tab in DK Post Sync for Google Docs before Google is connected, with a notice, disabled sync controls, and empty queue and activity tables
The Sync tab before Google is connected. Controls stay disabled until setup is complete.

Your site talks to Google directly, with credentials you control. No third-party server sits in between, and you can revoke access at any time from your Google account or by clicking Disconnect.

DK Post Sync for Google Docs, plugin FAQ

How to Use It After You Connect

Once the connection and folder are in place, day-to-day use is mostly hands off. Publish or update a post as you normally would. The plugin queues the change and writes the Doc in the background. If Google revokes or expires the connection, syncing stops, post changes keep queueing, and a notice asks you to reconnect.

By default the plugin asks only for the drive.file scope. With it, the plugin can see and change only the files and folders it creates, so it creates its own folder for your Docs. If you need Docs written into a folder you made yourself, or one in a shared drive, switch to full Google Drive access (the drive scope) on the Google Connection tab and reconnect. With the recommended drive.file access, Google will not let the plugin use a folder you pasted in.

You can rename or move the folder in Drive without breaking syncing, because the plugin tracks it by ID. To give Gemini, an MCP client, or a teammate access to the knowledge base, share the folder in Google Drive. Only published posts of the post type that are not password-protected are synced. Drafts, private posts, and password-protected posts are never sent.

If your consent screen is External and still in Testing, Google expires refresh tokens after 7 days. Use an Internal consent screen with Google Workspace, or publish the app, then reconnect. You can also keep the client ID and secret out of the database by adding these lines to wp-config.php, above the “That’s all, stop editing!” line:

define( 'DKNM_GDOCS_CLIENT_ID', 'your-client-id.apps.googleusercontent.com' );
define( 'DKNM_GDOCS_CLIENT_SECRET', 'your-client-secret' );

When those constants are defined, the matching fields on the Google Connection tab are locked.

Privacy, Access, and Cleanup

I wanted a tool I would be comfortable running on this site, so the plugin talks only to Google, and only after an administrator sets up the connection. It does not contact any other service, and it never sends data to DK New Media.

  • Google OAuth 2.0 is used to sign in, refresh access, and revoke access when you disconnect or uninstall.
  • The Google Drive API is used to read the connected account, create the folder, and create, update, find, and trash the Docs. What gets sent is each published post’s title, content, URL, dates, author display name, categories, tags, excerpt, SEO fields, image URLs, and alt text.
  • The OAuth client secret and the Google token are stored in your WordPress database in options that are not autoloaded, and they are never shown on a page.
  • Disconnecting revokes the plugin’s access at Google and stops syncing. Uninstalling also revokes access and removes the plugin’s settings, the stored secret and token, the queue, and its post meta. Your Docs stay in Drive. If you reinstall and connect with the same OAuth client, the plugin finds each post’s existing Doc again instead of creating a duplicate.

Free, With No Upsells or Nag Notifications

This plugin is free, and it is licensed under the GPL. There is no premium version waiting behind a paywall, no upsell banner in your dashboard, and no recurring notice asking you to rate it or upgrade. I built it because I needed a current, shareable copy of Martech Zone’s published work for Gemini and our MCP tools, without opening the site to those tools, and I am sharing it because other publishers, agencies, and in-house teams have the same problem.

Ready to Keep Your AI Knowledge Base Current Without Opening the Site?

If you want Gemini, an MCP integration, or any other Drive-connected tool to work from your published posts, give them a folder of Docs instead of a WordPress login. The copies stay current, you can add a header that tells those tools how to use them, and the site itself stays closed.

View DK Post Sync for Google Docs in the WordPress Plugin Repository

Frequently Asked Questions

Why Do I Need My Own Google Cloud OAuth Client?

Your site talks to Google directly, with credentials you control. No third-party server sits in between, and you can revoke access at any time from your Google account or by clicking Disconnect.

Can I Keep the Client ID and Secret Out of the Database?

Yes. Define DKNM_GDOCS_CLIENT_ID and DKNM_GDOCS_CLIENT_SECRET in wp-config.php, above the That’s all, stop editing! line. When they are defined, the matching fields on the Google Connection tab are locked.

Why Does My Connection Stop Working After 7 Days?

When a consent screen is External and its publishing status is Testing, Google expires refresh tokens after 7 days. Use an Internal consent screen if you have Google Workspace, or publish the app, then reconnect.

Why Can’t the Plugin Use the Folder I Pasted?

With the recommended drive.file access, Google lets the plugin use only folders it created. Create the folder from the Settings tab, or switch to full Drive access on the Google Connection tab and reconnect.

Can I Rename, Move, or Share the Folder?

Yes. The plugin tracks the folder by its ID, so renaming or moving it in Drive does not break syncing. To share the Docs, share the folder in Google Drive.

Which Posts Are Synced?

Published posts of the post type that are not password-protected. Drafts, private posts, and password-protected posts are never sent. If a post that has a Doc stops being public, its Doc moves to the Drive trash.

Does Disconnecting or Uninstalling Delete My Docs?

No. Disconnecting revokes the plugin’s access at Google and stops syncing. Uninstalling also revokes access and removes the plugin’s settings, the stored secret and token, the queue, and its post meta. Your Docs stay in Drive. If you reinstall and connect with the same OAuth client, the plugin finds each post’s existing Doc again instead of creating a duplicate.

Does It Slow Down Saving Posts?

No. Saving a post only adds it to a queue. The Google requests run in the background through WP-Cron, or on the Sync tab while you have it open.

Can I Add a Header to Every Google Doc?

Yes. On Settings, then DK Post Sync, then Settings, there is an optional HTML field added at the top of every synced Doc. Leave it blank if you do not want a header. Allowed tags are the same as in posts. You can include the placeholders {post_title}, {permalink}, and {date}. {date} uses the date format from Settings, then General, and the post’s published date. After you change the header, click Sync All Posts on the Sync tab to update Docs that already exist.

Is the Plugin Really Free?

Yes. It is free in the WordPress plugin directory, with no upsells and no nag notifications.

Related Articles