WordPress Hooks

WordPress Hooks

From WordCamp Philly 2015 - Learn to get comfortable working with Action and Filter Hooks in WordPress

De0a01122ca4a619004332ab04431b7b?s=128

Zac Gordon

June 13, 2015
Tweet

Transcript

  1. 38.
  2. 40.
  3. 42.
  4. 45.
  5. 52.

    function body_class_example( $classes ) { if( is_single() ) { foreach(

    get_the_category( get_the_ID() ) as $cat ) $classes[] = 'cat-' . $cat->category_nicename; } return $classes; } add_filter( 'body_class', 'body_class_example' );
  6. 53.

    function register_my_menus() { register_nav_menus( array( 'footer_menu' => __( 'Footer Menu',

    'mytheme' ) ) ); } add_action( 'init', 'register_my_menus' );
  7. 54.

    function my_plugin_page() { add_options_page( 'Page Title', ‘Menu Title', 'manage_options', ‘plugin-slug',

    ‘my_plugin_page_init’ ); } add_action( 'admin_menu' , 'my_plugin_page' );
  8. 55.

    function publish_post_to_slack( ) { // Connect to Slack API }

    add_action( 'save_post', ‘publish_post_to_slack’ );