Get the best Black Friday & Cyber Monday deals right now!

Passing Parameters to Functions via Action Hooks

If you are using WordPress action hooks and want to pass some parameters to the function being called, this is the way to do it.

If you purchase through a link on our site, we may earn a commission.

If you are using WordPress action hooks and want to pass some parameters to the function being called, this is the way to do it:
[php]
do_action( ‘name-of-action’, $arg1, $arg2 );
[/php]
For example:
[php]
add_action(‘hook_before_post’,’recent_post_by_author’,10,2);
[/php]
If you enjoyed this post, make sure to subscribe to WP Mayor’s RSS feed.

Jean Galea is an investor, entrepreneur, and blogger. He is the founder of WP Mayor, the plugins WP RSS Aggregator and Spotlight, as well as the Mastermind.fm podcast. His personal blog can be found at jeangalea.com.

If you purchase through a link on our site, we may earn a commission.

More from our blog...

Post a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Stay updated with WP Mayor's newsletter showcase every week

Stay on top of every new WordPress innovation and latest launches. Receive all our fresh product reviews and expert guides directly in your inbox.