XebiaLabs Main Website / Blog Sync MODX Snippet

Something I’ve seen a lot of organizations struggling with is keeping their blog, website, and other web properties in “sync”, or at least being able to use content from the all of them in one place. For example, often times a company will want to pull their related “blog” content on their main website, or the other way around.

This was a situation that XebiaLabs routinely ran into so I came up with a creative solution to this problem by creating a Modx snippet, and hooking into Modx using a popular WordPress plugin called Hookpress.

Here is how it went.,,

Installing / Configuring HookPress

Screen Shot 2015-05-05 at 5.54.59 PM

Hookpress is a plugin for WordPress that allows you to post data to a url upon certain WordPress actions. I set the plugin to post a post’s title, id, content, description, and a ton of other data our main website whenever a user saved or updated a post.

Catching the Info

Once the data was sent all I needed to do was figure out what to do with it on the Modx end. What I did was create the below snippet which is by now much more secure and updated, but this is the initial crack I took at it.

In this snippet I:

  • Catch all of the fields sent to Modx
  • Check to see if the blog is already in the system by searching for a resource by the blog id
  • If the post exists I would update the content.
  • If the post didn’t exist I would simply create it.

Then after all of this I would go above and beyond and categorize the blog posts according the the taxonomies we had in Modx.

I would pull all of the taxonomy terms in Modx, perform a regex search for the term within the content of the blog post, and if the blog contained the term I would set the taxonomy.


This snippet allowed us to automate the synchronization of our blog content to our main website thus making the content more discoverable, integrated, and smooth.

We could then pull related blog posts on all of our pages instead of simply using an inflexible rss feed. We could include related blog posts in dynamically created emails powered by our CMS, and a ton of other stuff.

This snippet, as stupid, and trivial as it seems probably contributed to a good deal of traffic as well as pipeline for our company.