Understanding difference between do_action & add_action (3 posts)

  1. weex
    Posted 3 years ago #

    Hi all,

    I am having some trouble understanding the exact difference between the do_action and add_action functions. I've searched google and these forums, still am confused. Codex does not help me either.

    I understand the add_action function for writing a plugin that does something at a certain point in the WordPress flow using a call back function.

    But what is do_action? I see no callback function or anything when these are used. I guess I don't get the exact difference between the two and moreso the point or use of do_action when writing a custom plugin?

    Help from someone with more working knowledge than me explain the simple difference I am not able to grasp?

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    add_action allows you to hook a function on to a pre-existing action. do_action allows you to create a new action. A plugin might use do_action to create its own custom "hook" and then add functions to that hook in various scripts via add_action.

  3. manoj insa
    Posted 3 years ago #

    hi ,

    i am new in wordpress, i created one site in it. Now i want to create my plugin , so please tell me,, how i accomplished this..anyone help me Please !

Topic Closed

This topic has been closed to new replies.

About this Topic