Ichsan's Ebook
  • Journal
  • Wordpress Development
    • Rest API
      • /posts
      • Adding Custom Endpoint
    • Hooks
      • Actions
        • Actions Run During an Admin Page Request
          • set_current_user
          • admin_menu
          • admin_footer
        • Template Actions
          • switch_theme
          • after_switch_theme
      • Filters
    • Functions
      • register_post_type
      • add_shortcode
      • add_dashboard_page
      • add_posts_page
      • add_management_page
      • add_menu_page
      • add_submenu_page
      • dbDelta
      • wpdb::get_results
      • wpdb::get_row
      • wpdb::delete
    • Properties
      • wpdb::insert_id
      • wpdb::last_error
      • wpdb::num_rows
      • wpdb::prefix
    • Hands On Tips & Trick
      • Include PHP file to add_menu_page()
    • Utils Methods
      • __FILE__
      • dirname()
      • __()
    • Conditional Tags
      • is_home
      • is_front_page
      • is_admin
      • is_single
      • is_singular
    • Roles and Capabilities
  • Template Hierarchy
Powered by GitBook
On this page
  1. Wordpress Development
  2. Hooks

Actions

PreviousHooksNextActions Run During an Admin Page Request

Last updated 1 year ago

allow you to add data or change how WordPress operates. Actions will run at a specific point in the execution of WordPress Core, plugins, and themes. Callback functions for Actions can perform some kind of a task, like echoing output to the user or inserting something into the database. Callback functions for an Action do not return anything back to the calling Action hook.

They provide a way for running a function at a specific point in the execution of WordPress Core, plugins, and themes.

function wporg_callback() {
    // do something
}
add_action( 'init', 'wporg_callback' );

Above code will running wporg_callbackwhen init hook running.

add_init also support to ordering running of code using thrid parameter is for priority.

add_action('init', 'aa');
add_action('init', 'bb',1); // run first than aa function

Action which running with do_action()and does'nt have second paramater we cannot do more with it.

Actions