Support » Plugins » Should I use publish_post or the_content?

  • I am trying to write a plugin that does something extremely simple: it searches the content and replaces “foo” with “bar” when the user publishes a page. However, I want this change to be permanent: I want it to edit the content of the post as it’s going in the database. It appears that the_content action hook only edits a post between the database and the browser. However, publish_page only allows a parameter of the post_ID, and I’m not sure how to edit the content given only an ID.

Viewing 3 replies - 1 through 3 (of 3 total)
  • I could use help on a similar question…I’m wanting to disable trackbacks on pages only when a page is published. I’m having problems locating the action to do this, since it appears publish_page has been deprecated in 2.3. Any advice on how to a) find the hook for publishing a page (not just a post) and b) changing the ping_status to ‘closed’ when the page is published would be most helpful. Thanks.

    Okay…I figured mine out. This website will show you how to do exactly what you want it to. If you only want it to do it on pages, rather than all posts, let me know, I’ll show you how I did it.

    Whoops…linked to the wrong tab I had open…here’s the right one.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Should I use publish_post or the_content?’ is closed to new replies.