I’m having difficulty understanding the difference between Action and Filter functions.
to quote from codex:
Actions are triggered by specific events that take place in WordPress, such as publishing a post, changing themes, or displaying a page of the admin panel. Your plugin can respond to the event by executing a PHP function, which might do one or more of the following:
* Modify database data
* Send an email message
* Modify what is displayed in the browser screen (admin or end-user)
Filters are functions that WordPress passes data through, at certain points in execution, just before taking some action with the data (such as adding it to the database or sending it to the browser screen). Filters sit between the database and the browser (when WordPress is generating pages), and between the browser and the database (when WordPress is adding new posts and comments to the database);
So, are filters a subset of actions?
it seems I could use an action to change the text of the post for instance, instead of a filter?
what would be a good example of correctly using filters while actions would be inappropriate for the situation?
when should I use an action and when a filter?
do the ‘hooks’ for actions and filters overlap? -can I add a either a filter or an action to the same hook?
Thanks in advance for any answers and I apologize if this has been answered to death before but I could not find a forum post on this exactly..
- The topic ‘Filters vs Actions -from a newbe’ is closed to new replies.