Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // --- Create a shortcode
- // @Usage: [shortcode_name count="1"]
- function theme_shortcode_add_name($args) {
- $html = '';
- $count = !empty($args['count']) ? $args['count'] : 5;
- return $html;
- }
- add_shortcode( 'shortcode_name', 'theme_shortcode_add_name' );
- // --- Add a custom post type to REST
- function theme_add_events_to_json_api() {
- $types = get_post_types(array('public' => true, '_builtin' => false));
- global $wp_post_types;
- foreach ($types as $type) {
- $wp_post_types[$type]->show_in_rest = true;
- $wp_post_types[$type]->rest_base = $type;
- $wp_post_types[$type]->rest_controller_class = 'WP_REST_Posts_Controller';
- }
- }
- add_action( 'init', 'theme_add_events_to_json_api', 30 );
- // --- Add a menu
- function theme_add_nav_menu() {
- register_nav_menus(
- array(
- 'main-menu' => __( 'Main Menu', 'themename' )
- )
- );
- }
- add_action( 'after_setup_theme', 'theme_add_nav_menu' );
- // --- Add a widget
- function theme_widgets_init() {
- register_sidebar( array (
- 'name' => __( 'Homepage Widget Area', 'theme' ),
- 'id' => 'homepage-widget-area',
- 'before_widget' => '',
- 'after_widget' => '',
- 'before_title' => '',
- 'after_title' => '',
- ) );
- }
- add_action( 'widgets_init', 'theme_widgets_init' );
Add Comment
Please, Sign In to add comment