Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Register a Custom Menu in the Admin
- function register_my_custom_menu_page() {
- add_menu_page( 'custom menu title', 'custom menu', 'manage_options', 'myplugin/myplugin-admin.php', '', 'dashicons-admin-site', 6 );
- }
- add_action( 'admin_menu', 'register_my_custom_menu_page' );
- Change the Excerpt Length
- function excerpt_length_example( $words ) {
- return 15;
- }
- add_filter( 'excerpt_length', 'excerpt_length_example' );
- Hook into Post Publishing
- function publish_post_tweet($post_ID) {
- global $post;
- // Code to send a tweet with post info
- }
- add_action('publish_post', 'publish_post_tweet');
- Hook Into Widget Initialization
- function create_my_widget() {
- register_sidebar(array(
- 'name' => __( 'My Sidebar', 'mytheme' ),
- 'id' => 'my_sidebar',
- 'description' => __( 'The one and only', 'mytheme' ),
- ));
- }
- add_action( 'widgets_init', 'create_my_widget' );
- Hook Into Front-end Scripts and Styles
- function theme_styles() {
- wp_enqueue_style( 'bootstrap_css', get_template_directory_uri() . '/css/bootstrap.min.css' );
- wp_enqueue_style( 'main_css', get_template_directory_uri() . '/style.css' );
- wp_enqueue_script( 'bootstrap_js', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '', true );
- wp_enqueue_script( 'theme_js', get_template_directory_uri() . '/js/theme.js', array('jquery', 'bootstrap_js'), '', true );
- }
- add_action( 'wp_enqueue_scripts', 'theme_styles' );
Advertisement
Add Comment
Please, Sign In to add comment