WordPress.org

Ready to get started?Download WordPress

Forums

Should I use publish_post or the_content? (4 posts)

  1. alais5
    Member
    Posted 6 years ago #

    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.
    Thanks.

  2. klitscher
    Member
    Posted 6 years ago #

    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.

  3. klitscher
    Member
    Posted 6 years ago #

    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.

  4. klitscher
    Member
    Posted 6 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.