Last active
August 29, 2015 14:10
-
-
Save vishalbasnet23/b09fe77bf743661f3f97 to your computer and use it in GitHub Desktop.
Essential Snippets For Wordpress
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
| <snippet> | |
| <content><![CDATA[ | |
| /**************************************/ | |
| /* Registering post type */ | |
| /**************************************/ | |
| add_action('init','register_post_type_gallery'); | |
| function register_post_type_gallery() { | |
| $labels = array( | |
| 'name' => __('Gallery','_cp'), | |
| 'singular_name' => __('Gallery','_cp'), | |
| 'add_new' => __('Add New','_cp'), | |
| 'add_new_item' => __('Add New Gallery','_cp'), | |
| 'edit_item' => __('Edit Gallery','_cp'), | |
| 'new_item' => __('New Gallery','_cp'), | |
| 'all_items' => __('All Galleries','_cp'), | |
| 'view_item' => __('View Gallery','_cp'), | |
| 'search_items' => __('Search Galley','_cp'), | |
| 'not_found' => __('No Gallery found','_cp'), | |
| 'not_found_in_trash' => __('No Gallery found in Trash','_cp'), | |
| 'parent_item_colon' => '', | |
| 'menu_name' => __('Gallery','_cp') | |
| ); | |
| $args = array( | |
| 'labels' => $labels, | |
| 'description' => __('Holds all the galley','_cp'), | |
| 'public' => true, | |
| 'supports' => array( 'title' ), | |
| 'has_archive' => true, | |
| 'hierarchical' => true, | |
| // 'menu_icon' => get_bloginfo('template_url').'/images/icons/interview-icon.png', | |
| ); | |
| register_post_type( 'code_gallery', $args ); | |
| } | |
| ]]></content> | |
| <!-- Optional: Set a tabTrigger to define how to trigger the snippet --> | |
| <tabTrigger>wpposttype</tabTrigger> | |
| <!-- Optional: Set a scope to limit where the snippet will trigger --> | |
| <scope>source.php</scope> | |
| </snippet> |
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
| <snippet> | |
| <content><![CDATA[ | |
| function frontend_script() { | |
| wp_enqueue_script( 'script-handle', get_template_directory_uri() . '/path', array( 'jquery' ) ); | |
| wp_enqueue_style( 'style-handle', get_template_directory_uri(). '/path' ); | |
| } | |
| add_action( 'wp_enqueue_scripts', 'frontend_script' ); | |
| ]]></content> | |
| <!-- Optional: Set a tabTrigger to define how to trigger the snippet --> | |
| <tabTrigger>wpscripts</tabTrigger> | |
| <!-- Optional: Set a scope to limit where the snippet will trigger --> | |
| <scope>source.php</scope> | |
| </snippet> |
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
| <snippet> | |
| <content><![CDATA[ | |
| while ( have_posts() ) : the_post(); | |
| // Include the page content template. | |
| get_template_part( 'content', 'page' ); | |
| endwhile; | |
| ]]></content> | |
| <!-- Optional: Set a tabTrigger to define how to trigger the snippet --> | |
| <tabTrigger>wpwhileloop</tabTrigger> | |
| <!-- Optional: Set a scope to limit where the snippet will trigger --> | |
| <scope>source.php</scope> | |
| </snippet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment