Support » Plugins and Hacks » Creating custom tag plugin question

Creating custom tag plugin question

  • I have a custom tag plugin that I am writing and I want it to directly edit the post in the database. I want this to happen when the post is created and whenever it is edited.

    This way once you use the custom tag the results are saved in the post and the tag disapears leaving the reformatted text.

    I have surmised that I need to run the plugin as an action like so:

    add_action('edit_post', 'function_name');
    add_action('edit_post', 'function_name');
    add_action('publish_post', 'function_name');
    add_action('publish_post', 'function_name');

    The issue is that the publish_post and edit_post hooks return the post id. What is the best way to access the content of the database for the post? Is there a global database connection object I can use to run my query against? How is it best used for backwards compatibility?


Viewing 1 replies (of 1 total)
  • TechGnome



    When ever I’ve needed to get at the post, I use the post_id and run a query to return the posting. Then I modify it, and execute another query to update the data back again.

    Another option is to use the filter for “format_to_post” or “the_content” they get passed in the content of the post itself. Now, these happen right before the content is displayed, and so the changes would not be saved. This may or maynot be preferable – but just think about what you would like to have happen if you, say deactivated or deleted the plugin.


Viewing 1 replies (of 1 total)
  • The topic ‘Creating custom tag plugin question’ is closed to new replies.