Guest User

Untitled

a guest
Dec 16th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. <?php
  2. // --- Create a shortcode
  3. // @Usage: [shortcode_name count="1"]
  4. function theme_shortcode_add_name($args) {
  5. $html = '';
  6. $count = !empty($args['count']) ? $args['count'] : 5;
  7. return $html;
  8. }
  9. add_shortcode( 'shortcode_name', 'theme_shortcode_add_name' );
  10.  
  11. // --- Add a custom post type to REST
  12. function theme_add_events_to_json_api() {
  13. $types = get_post_types(array('public' => true, '_builtin' => false));
  14. global $wp_post_types;
  15. foreach ($types as $type) {
  16. $wp_post_types[$type]->show_in_rest = true;
  17. $wp_post_types[$type]->rest_base = $type;
  18. $wp_post_types[$type]->rest_controller_class = 'WP_REST_Posts_Controller';
  19. }
  20. }
  21. add_action( 'init', 'theme_add_events_to_json_api', 30 );
  22.  
  23. // --- Add a menu
  24. function theme_add_nav_menu() {
  25. register_nav_menus(
  26. array(
  27. 'main-menu' => __( 'Main Menu', 'themename' )
  28. )
  29. );
  30. }
  31. add_action( 'after_setup_theme', 'theme_add_nav_menu' );
  32.  
  33. // --- Add a widget
  34. function theme_widgets_init() {
  35. register_sidebar( array (
  36. 'name' => __( 'Homepage Widget Area', 'theme' ),
  37. 'id' => 'homepage-widget-area',
  38. 'before_widget' => '',
  39. 'after_widget' => '',
  40. 'before_title' => '',
  41. 'after_title' => '',
  42. ) );
  43. }
  44. add_action( 'widgets_init', 'theme_widgets_init' );
Add Comment
Please, Sign In to add comment