for posts and comments. add_theme_support( 'automatic-feed-links' ); // This theme supports a variety of post formats. add_theme_support( 'post-formats', array( 'aside', 'image', 'link', 'quote', 'status' ) ); /* * This theme supports custom background color and image, * and here we also set up the default background color. */ add_theme_support( 'custom-background', array( 'default-color' => '84C680', ) ); $args = array( 'header-text' => false, 'default-text-color' => '000', 'width' => 360, 'height' => 150, 'random-default' => false, 'uploads' => true, ); add_theme_support( 'custom-header', $args ); // This theme uses a custom image size for featured images, displayed on "standard" posts. add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 200, 200 ); // Unlimited height, soft crop } add_action( 'after_setup_theme', 'grassy_setup' ); /* This code for theme options */ add_filter( 'ot_show_pages', '__return_false' ); add_filter( 'ot_show_new_layout', '__return_false' ); add_filter( 'ot_theme_mode', '__return_true' ); load_template( get_template_directory() . '/option-tree/ot-loader.php' ); load_template( get_template_directory() . '/includes/theme-options.php' ); //Register Navigations add_action( 'init', 'grassy_my_custom_menus' ); function grassy_my_custom_menus() { register_nav_menus( array( 'primary-menu' => __( 'Grassy Primary Menu', 'grassy' ), ) ); } function grassy_widget_areas() { /*sidebar*/ register_sidebar(array( 'name' =>__('Right Hand Sidebar'), 'id' => 'right-sidebar', 'description'=>__('right in the sidebar'), 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', )); /*Footer 1 Widget Area*/ register_sidebar( array( 'name' => __( 'Footer 1', 'grassy' ), 'id' => 'widget1', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); /*Footer 2 Widget Area*/ register_sidebar( array( 'name' => __( 'Footer 2', 'grassy' ), 'id' => 'widget2', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); /*Footer 3 Widget Area*/ register_sidebar( array( 'name' => __( 'Footer 3', 'grassy' ), 'id' => 'widget3', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); } add_action('widgets_init', 'grassy_widget_areas'); // function to display number of posts. function grassy_getPostViews($postID){ $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); return "0 View"; } return $count.' Views'; } // function to count views. function grassy_setPostViews($postID) { $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ $count = 0; delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); }else{ $count++; update_post_meta($postID, $count_key, $count); } } // Add it to a column in WP-Admin add_filter('manage_posts_columns', 'posts_column_views'); add_action('manage_posts_custom_column', 'posts_custom_column_views',5,2); function posts_column_views($defaults){ $defaults['post_views'] = __('Views', 'grassy'); return $defaults; } function posts_custom_column_views($column_name, $id){ if($column_name === 'post_views'){ echo getPostViews(get_the_ID()); } } /* This code for Featured Image Support */ add_image_size( 'post-image', 120, 120, true ); add_image_size( 'grassy-related-image', 75, 75, true ); function grassy_numeric_posts_nav() { if( is_singular() ) return; global $wp_query; /** Stop execution if there's only 1 page */ if( $wp_query->max_num_pages <= 1 ) return; $paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1; $max = intval( $wp_query->max_num_pages ); /** Add current page to the array */ if ( $paged >= 1 ) $links[] = $paged; /** Add the pages around the current page to the array */ if ( $paged >= 3 ) { $links[] = $paged - 1; $links[] = $paged - 2; } if ( ( $paged + 2 ) <= $max ) { $links[] = $paged + 2; $links[] = $paged + 1; } echo '' . "\n"; } if ( ! function_exists( 'grassy_comment' ) ) : /** * Template for comments and pingbacks. * * Used as a callback by wp_list_comments() for displaying the comments. * * @since Grassy 1.0 */ function grassy_comment( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; switch ( $comment->comment_type ) : case 'pingback' : case 'trackback' : ?>
  • id="li-comment-">
    says:', 'Grassy' ), sprintf( '%s', get_comment_author_link() ) ); ?>
    comment_approved == '0' ) : ?>
    $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
    '."\n"; } } } add_filter( 'wp_head', 'grassy_favicon' ); function grassy_enqueue_script() { wp_enqueue_style( 'grassy-style',get_stylesheet_directory_uri().'/style.css'); } add_action( 'wp_enqueue_scripts', 'grassy_enqueue_script' ); function grassy_wp_title( $title, $sep ) { global $paged, $page; if ( is_feed() ) return $title; // Add the site name. $title .= get_bloginfo( 'name' ); // Add the site description for the home/front page. $site_description = get_bloginfo( 'description', 'display' ); if ( $site_description && ( is_home() || is_front_page() ) ) $title = "$title $sep $site_description"; // Add a page number if necessary. if ( $paged >= 2 || $page >= 2 ) $title = "$title $sep " . sprintf( __( 'Page %s', 'grassy' ), max( $paged, $page ) ); return $title; } add_filter( 'wp_title', 'grassy_wp_title', 10, 2 ); ?>