Upgrade to Pro — share decks privately, control downloads, hide ads and more …

WordPress Hooks

WordPress Hooks

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

Zac Gordon

June 13, 2015

Transcript

57 slides
  1. 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' );
  2. function register_my_menus() { register_nav_menus( array( 'footer_menu' => __( 'Footer Menu',

    'mytheme' ) ) ); } add_action( 'init', 'register_my_menus' );
  3. 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' );
  4. function publish_post_to_slack( ) { // Connect to Slack API }

    add_action( 'save_post', ‘publish_post_to_slack’ );

More Decks by Zac Gordon

Other Decks in Technology