what is do_action(); in wordpress? [duplicate]

It’s actually used by WP to allow plugin developers change WP behavior. You can make your code flexible using do_action so other plugin/theme developers or simply yourself can change behavior of your code.

For example imagine you have a WP loop in a theme framework. You would like to add breadcrumb at the top of it, here is the simplest method:

...
<?php print_breadcrumb(); ?>
<h2><?php the_title(); ?></h2>
...

But this way plugin developers or site authors require to edit print_breadcrumb() at functions.php to add their own breadcrumbs. Better way is using do_action()

...
<?php do_action('breadcrumb') ?>
<h2><?php the_title(); ?></h2>
...

Now you can add this in functions.php to get same behavior:

add_action('breadcrumb', 'print_breadcrumb'); 

Now a plugin author may override your code by:

add_action('breadcrumb', 'their_own_breadcrumb');