Feb 172012
 

After looking at about a zillion different options I ended up with Leo Charre’s WordPress CLI CPAN package for uploading posts… and after a bit of tinkering got it to work with 3.x WP.  However… it didn’t support tags, which I really needed for the project I’m working on.   This handy pointer to how to do it to java saved my bacon: it turns out that making a very small modification to the code enabled tagging.

Why WP doesn’t support this natively is entirely beyond me.  But putting the magic “mt_keywords” in the struct with w/e values you want seems to do the job.  Small change to the perl code in case anyone else is looking for this stuff (diff/etc. sent to LC, of course.)   Using the mod’d code you can do things like (added the -T for tags):

wordpress-upload-post -d post-text-file  -t "Post Title" -c "Nmap-Category" -T "red fish, blue fish, two fish"

Of course you can’t use 2 subcategories with the same name in the WP XMLRPC interface either (why they test for names vs. id’s….), but that’s just another sad tale in tech.  The salient line:

<pre>if ($opt_T){ $struct->{mt_keywords} = $opt_T; }</pre>

Perl program attached, but needs the supporting libs from CPAN.

[attachments]

Attachments

  One Response to “command line perl posting to WP”

  1. […] little things.  Beat on that old perl script and added support… a few lines of code, a lot of beating my head against the wall, but I […]

Sorry, the comment form is closed at this time.