function.php

<?php/** * Enqueue Scripts and Styles */function theme_enqueue_styles() {
// Get the theme data $the_theme = wp_get_theme();
wp_enqueue_style( 'main-css', get_stylesheet_uri(), array(), $the_theme->get( 'Version' ));
wp_enqueue_style( 'my-css', get_stylesheet_directory_uri().'/mystyle.css', array(), $the_theme->get( 'Version' ));
wp_enqueue_style( 'bootstrap-css', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
wp_enqueue_script( 'jquery-script', 'https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js');
wp_enqueue_script( 'bootstrap-script', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js');
}
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
/** * Register Primary Menus */function register_primary_menu() {
register_nav_menu( 'primary', __( 'Primary Menu', 'theme-slug' ) );
}
add_action( 'after_setup_theme', 'register_primary_menu' );
/** * Register Footer Menus */function register_footer_menu() {
register_nav_menu( 'footer', __( 'Footer Menu', 'theme-slug' ) );
}
add_action( 'after_setup_theme', 'register_footer_menu' );
/** * Custom Excerpt */if ( ! function_exists( 'custom_excerpt_more' ) ) {
function custom_excerpt_more( $more ) {
return '';
}
}
add_filter( 'excerpt_more', 'custom_excerpt_more' );
if ( ! function_exists( 'all_excerpts_get_more_link' ) ) {
function all_excerpts_get_more_link( $post_excerpt ) {
return $post_excerpt . '...<p><a class="btn btn-secondary theme-slug-read-more-link" href="' . get_permalink( get_the_ID() ) . '">' . __( 'Read More', 'theme-slug' ) . '</a></p>';
}
}
add_filter( 'wp_trim_excerpt', 'all_excerpts_get_more_link' );
/** * Custom Post Type */function register_custom_post_type_grant_recipients() {
$singular = 'Grant Recipient';
$plural = 'Grant Recipients';
$description = 'Custom post type for all grant recipients of Catlyst Foundation';
$slug = 'grant-recipients';
$post_type = 'grant_recipients';
$labels = array(
'name' => $plural,
'singular_name' => $singular,
'menu_name' => $plural,
'name_admin_bar' => $plural,
'archives' => $singular.' Archives',
'attributes' => $singular.' Attributes',
'parent_item_colon' => 'Parent '.$singular,
'all_items' => 'All '.$plural,
'add_new_item' => 'Add New '.$singular,
'add_new' => 'Add New',
'new_item' => 'New '.$singular,
'edit_item' => 'Edit '.$singular,
'update_item' => 'Update '.$singular,
'view_item' => 'View '.$singular,
'view_items' => 'View '.$plural,
'search_items' => 'Search '.$plural,
'not_found' => 'No '.$plural.' found',
'not_found_in_trash' => 'No '.$plural.' found in Trash',
'featured_image' => 'Featured Image',
'set_featured_image' => 'Set featured image',
'remove_featured_image' => 'Remove featured image',
'use_featured_image' => 'Use as featured image',
'insert_into_item' => 'Insert into '.$singular,
'uploaded_to_this_item' => 'Uploaded to this '.$singular,
'items_list' => $singular.' list',
'items_list_navigation' => $singular.' list navigation',
'filter_items_list' => 'Filter '.$singular.' list',
);
$args = array(
'label' => $plural,
'description' => $description,
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'revisions', 'custom_fields', 'page-attributes', 'post-formats', ),
'taxonomies' => array( $post_type ),
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 6,
'menu_icon' => 'dashicons-welcome-learn-more',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => $slug,
'exclude_from_search' => false,
'publicly_queryable' => true,
'rewrite' => array( 'slug' => $slug ),
'capability_type' => 'post',
);
register_post_type( $post_type, $args );
}
add_action( 'init', 'register_custom_post_type_grant_recipients' );
/**Remove editor from this custom post type*/function init_remove_editor(){
$post_type = 'grant_recipients';
remove_post_type_support( $post_type, 'editor');
}
add_action('init', 'init_remove_editor', 100);
/** Adding Taxonomy(Category) to custom post type
*/ function create_custom_grant_recipients_taxonomies() {
// Add new taxonomy, make it hierarchical (like categories) $singular = 'Grant Recipient Category';
$plural = 'Grant Recipient Categories';
$description = 'Custom post category(taxonomy) for all grant recipients of Catlyst Foundation';
$slug = 'grant-recipient-category';
$parent_post_type = 'grant_recipients';
$labels = array(
'name' => _x( $plural, 'taxonomy general name', 'textdomain' ),
'singular_name' => _x( $singular, 'taxonomy singular name', 'textdomain' ),
'search_items' => __( 'Search '.$plural, 'textdomain' ),
'all_items' => __( 'All Categories', 'textdomain' ),
'parent_item' => __( 'Parent Category', 'textdomain' ),
'parent_item_colon' => __( 'Parent Category:', 'textdomain' ),
'edit_item' => __( 'Edit '.$singular, 'textdomain' ),
'update_item' => __( 'Update '.$singular, 'textdomain' ),
'add_new_item' => __( 'Add New '.$singular, 'textdomain' ),
'new_item_name' => __( 'New '.$singular.' Name', 'textdomain' ),
'menu_name' => __( $plural, 'textdomain' ),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => $slug ),
);
register_taxonomy( $parent_post_type, array( $parent_post_type ), $args );
}
add_action( 'init', 'create_custom_grant_recipients_taxonomies', 0 );
/***Change Posts menu name to News title*/function change_post_menu_label() {
$singular = 'News';
$plural = 'News';
global $menu;
global $submenu;
$menu[5][0] = $plural;
$submenu['edit.php'][5][0] = $singular;
$submenu['edit.php'][16][0] = $singular.' Tags';
echo '';
}
add_action( 'admin_menu', 'change_post_menu_label' );
/***Change few Posts menu options to News title*/function change_post_object_label() {
$singular = 'News';
$plural = 'News';
global $wp_post_types;
$labels = &$wp_post_types['post']->labels;
$labels->name = $plural;
$labels->singular_name = $singular;
$labels->edit_item = 'Edit '.$singular;
$labels->new_item = 'New '.$singular;
$labels->view_item = 'View '.$singular;
$labels->search_items = 'Search '.$plural;
$labels->not_found = 'No '.$singular.' found';
$labels->not_found_in_trash = 'No '.$singular.' found in Trash';
}
add_action( 'init', 'change_post_object_label' );
// Make Visual the default tabadd_filter( 'wp_default_editor', create_function('', 'return "tinymce";') );
/** * Disable content pagination for post post type in the main loop * * @link http://wordpress.stackexchange.com/a/208784/26350 */add_filter( 'content_pagination', function( $pages, $post )
{
$post_type = 'grant_recipients';
if ( in_the_loop() && $post_type === $post->post_type )
$pages = [ join( '', $pages ) ];
return $pages;
}, 10, 2 );

Labels: , , ,

© copyright-2020 Rejaul