I am trying to insert a post with a custom post type, which I also want to attach custom taxonomies. Most of the patches available are outdated any only apply to “xmlrpc.php”. Now the file in wordpress that controls the function is “class-wp-xmlrpc-server.php”. Could someone give me advice on how to dissect the file? I would prefer to add a filter to my theme file rather than overwriting WordPress core files.
Leave a Reply
You must be logged in to post a comment.
I realize that this is an old topic, but I’ve been wondering the same thing in the last couple of weeks and totally rewrote some of that file to work with what I needed it to do. For my implementation, I have a custom post type called ‘blog’, with custom taxonomies called ‘blog_categories’ and ‘blog_tags’. A little redundant, yes, but it was an experiment sort of.
If you take a look at
class-wp-xmlrpc-server.php
, you’ll notice that it’s a bit messy (depending on the version of WP you are using it may be better or worse). The easiest way I found to go about it without breaking anything was to go ahead and change the taxonomy functions to the generic ones rather than the category and post specific ones. That involves finding all of the instances ofwp_get_post_categories
andwp_get_post_tags
and replacing them with the more genericwp_get_object_terms
, and replacingget_categories
withget_terms
. Once this works usingcategories
andtags
as the taxonomy, you can do one of two things:post
toblog
,categories
toblog_categories
, etc. I just replaced the literals and my new XML-RPC allowed me to use Live Writer like normal, but it would use my custom post type and taxonomies.user_can('edit'_.$post_type, $postid)
.Sadly, WordPress is victim to the 1 post type, 2 post types (pages), n post types (custom) evolutionary model, and XML-RPC hasn’t gotten as much love as the rest of the system. There are some filter/action hooks in there you could investigate, but I think you’ll have an easier time just modifying the core file. This means your modifications will be overwritten on core updates though!
Hope this helps a little for you and anyone else looking to do the same thing!