Created
March 17, 2020 22:07
-
-
Save bstonedev/bd2d74c80073d7b4e17f353c0743d5f3 to your computer and use it in GitHub Desktop.
WP Theme Starter Code Snippets for Functions.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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