Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bstonedev/bd2d74c80073d7b4e17f353c0743d5f3 to your computer and use it in GitHub Desktop.
Save bstonedev/bd2d74c80073d7b4e17f353c0743d5f3 to your computer and use it in GitHub Desktop.
WP Theme Starter Code Snippets for Functions.php
<?php
/**
* Remove admin bar
**/
add_filter('show_admin_bar', '__return_false');
/**
* Register Custom Post Type
**/
function register_custom_posts_init() {
register_post_type(
'case-study',
array(
'labels' => array(
'name' => 'Case Studies',
'singular_name' => 'Case Study',
'menu_name' => __('Case Study')
),
'public' => true,
'capability_type' => 'post',
'has_archive' => false,
// 'taxonomies' => array( 'category' ),
'supports' => array( 'title', 'editor', 'excerpt', 'revisions', 'thumbnail'),
'show_in_rest' => true, //Enables Gutenberg editor
'menu_icon' => 'dashicons-format-aside',
'menu_position' => 5
)
);
}
add_action('init', 'register_custom_posts_init');
/**
* Add Advanced Custom Fields Options page
**/
if( function_exists('acf_add_options_page') ) {
acf_add_options_page();
}
/**
* Enqueue Custom CSS
**/
wp_enqueue_style('custom_css', get_template_directory_uri() . '/css/custom.css');
/**
* Enqueue Custom JS
**/
wp_enqueue_script('slick-carousel-js', get_template_directory_uri().'/js/slick.js', array(), date("Y-m-d"), true);
/**
* Enqueue Custom JS for specific page template
**/
if(is_page_template( 'template/template-name.php')){
wp_enqueue_script('template-name-js','js/template-name.js', array(), date("Y-m-d"), true);
};
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment