I’ve been using WordPress since 2005, hacking themes since 2008, and doing a whole lot more since then.. yet I have never written a plugin. All of my custom code has been done in theme templates and functions.php files

Well, now I have done so, without spilling much blood.

This is also the first time I have written something with a proper PHP class.

As usual I came across a wide swath of how to posts, many of them as helpful as echoing Hello World level complexity. I found Francis Yaconiello’s How to write a WordPress plugin good for giving a solid foundation for elements to include, I plucked bits from the WordPress Plugin Developer Guidelines. And because my plugin needed to create and respond to a form, jaskokyn’s How to Create a WordPress Admin Form was of assistance too.

I do find it worth noting that I rarely get my answer in a single tutorial, I have to mix and match (and discard often).

Do not get to excited, this is not very exciting. And I bet Martin Hawksey has already done something way more elaborate.

The folks I am working with on DML Commons are doing some research on the interactions and were looking for some data from the blog syndication. I’ve looked at a smattering of WordPress stats tools, and they all are like log data, and are presented only to the admin side. I was thinking there might be something that does slick charts and graphs and stuff for the public side (I bet there is, one cannot find everything out there).

But there was nothing even I could find that would give them some basic data by category for the syndicated posts (things brought into the blog hub via Feed WordPress). My first effort was to do a one off custom script that generated the following in CSV format:

  • post ID
  • source indicated (either ‘local’ or ‘syndicated’)
  • post title
  • publication date and time
  • author name (first and last name from profile, this is added to user profiles via the gravity form signup thing I built)
  • author username on site
  • blog name (host blog or remote blog if syndicated post)
  • post character count (string character count after HTML stripped out)
  • post word count (after HTML stripped out)
  • number of links in post (count of ‘‘ tags)
  • list of hyperlink urls (from all href= tags, hoping my regex is on target)

I set up a duplicate of the site on a dev server, and sent them a few links to export the data for the two different strands, Professional PathWays and Design Research (because of the syndication design, these posts get put into categories). This was supposed to be just a test of the functionality.

They said, “thanks this is perfect!”


I really need to start rolling some of my things into plugins so they can be use elsewhere w/o needing the theme hacking.

So in a few hours this morning I got a working plugin, now a very alpha version on github as Export Post Data to CSV. When activated, it adds a Post CSV Export item to the WordPress Tools menu. Nothing sophisticated:

My big fat plugin

My big fat plugin

You can choose to export data on all posts, or from within a category. The wp_dropdown_categories() function is handy as it can generate the menu, including an item for All Categories, keeping the category hierarchy, and even including a post count. I have it running here on my blog:

CogDogBlog Sloppy Category menu selector

CogDogBlog Sloppy Category menu selector

Then you click the Blue Button.

The script generates the CSV data which you then choose where to download. I did an export on my category for Syndicated posts from my Barking Dog Studios site (I bring in posts there from a category on that site I go “inside the photo”).

Boom! Barking Dog Category CSV Data

Screen shot of CSV data

Screen shot of CSV data

I do not know how helpful this kind of data per post is. Ideally we’d like to cross it by time maybe with twitter data. What else might there be worth extracting from posts? I can already see that I could get tags and categories.

This on its own is not big, but now I have the method started. For the upcoming projects, I am hoping to roll into a plugin a lot of the functionality I have been hand coding into the Feed WordPress sites I have been building. This way we could potentially make it easier for people to create a Connected Course. I can see having:

  • A Shortcode for adding a user sign up form, without needing gravity forms (including the logic to add the data to Feed WordPress directly
  • The Shortcodes I use for generating the blog lists
  • A script to generate OPML feeds for categories of blogs

But at least now I have grown up, written a plugin, and can shave like a big boy.

If this kind of stuff has value, please support me by tossing a one time PayPal kibble or monthly on Patreon
Become a patron at Patreon!
Profile Picture for CogDog The Blog
An early 90s builder of the web and blogging Alan Levine barks at CogDogBlog.com on web storytelling (#ds106 #4life), photography, bending WordPress, and serendipity in the infinite internet river. He thinks it's weird to write about himself in the third person. And he is 100% into the Fediverse (or tells himself so)


  1. Nice! We definitely need to improve the mother child blog setup workflow we have going at VCU. Will be following this plugin closely…

      1. Well, it does seem to get the job done – which is more than can be said about a lot of the muck I write.

  2. Dog, you are always doing cool stuff on this web thing. Thanks, as always for writing it all up!

  3. I’m in that same world (nothing shipped yet but plans….plans everywhere!). I’ve found Pippin’s Plugins to be essential https://pippinsplugins.com/. Cheap to support his work and the content is extremely accessible to novices like me that have a basic understanding of WordPress and are ready to dive in with plugin development. I’m working my way through his 101 series these next few weeks. https://pippinsplugins.com/series/plugin-development-101/

Leave a Reply

Your email address will not be published. Required fields are marked *