0

My "links" come in from Windows Live Writer, from a perl based delicious sync directly to the database and who knows where from. They all have in common that the category is 'Daily-Links'. So I think I will schedule a cron that every day checks for all posts in the category 'Daily Links' and then adds the post format type 'format-link' to it.

(since e.g. WLW does not support 'post formats') Or is there a better approach?

I wanted to kick this off by running a SQL query since it are probably hunderds of posts (for each object_id,term_taxonomy_id pair which has not already term_taxonomy_id=(id of format-link) AND which has the term_taxonomy_id of (the specific category) DO add the term_taxonomy_id of the format-link)

But... maybe there is already a WP function call for this? Is there?

2
  • 1
    Are you talking about custom post types or post formats (which are not custom)? What you can do is watch the incoming posts from Windows Live Writer and apply the correct post format or post type there, if the category is set. I once wrote some code that did this, I can look it up if you want.
    – Jan Fabry
    May 27, 2011 at 16:20
  • Only post formats (yes sorry, no custom... well...except for custom post'types post formats but not in this case). Yes for XMLRPC I probably could write an updater and for other stuff like wordpress.org/extend/plugins/… I would have to update the code (@todo). For the initial LOAD of existing posts I probably do a one time SQL action. uhm well.. that was basically the question: if that is the way to do it.
    – edelwater
    May 27, 2011 at 17:39

1 Answer 1

1

Hook save_post and add the post format if the post is for that category.

(save_post) Runs whenever a post or page is created or updated, which could be from an import, post/page edit form, xmlrpc, or post by email.

1
  • yep but not on my plugin: plugins.svn.wordpress.org/… (see also above, running 6 years with a prob) but its time to discard that one anyway or update it. the hook is handy yes, thanks. Now only the sql for performing the mass update for legacy posts....
    – edelwater
    May 27, 2011 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.