/ Published in: PHP

URL: xmawpfunc
function files for worpdress
Expand |
Embed | Plain Text
//when theme fire up... add_action('after_setup_theme','themeoptions', 16); function themeoptions(){ //include additional files require_once(TEMPLATEPATH . '/theme/themeoptions.php'); load_theme_textdomain( 'mytheme', TEMPLATEPATH.'/languages' ); // Excerpt more e title post cut function new_excerpt_more( $more ) { global $post; return ' <a class="moretag" href="'. get_permalink($post->ID) . '"> ' . __( 'Read more', 'mytheme' ) . '...</a> '; } add_filter('excerpt_more', 'new_excerpt_more'); function excerpt_length($length) { return 60; } add_filter('excerpt_length', 'excerpt_length'); function snip_title($limit) { global $post; $title = get_the_title($post->ID); if (strlen($title) > $limit){ $title = substr($title, 0, $limit) . '...'; echo $title; }else{ echo $title; } } //sidebar widget if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'Sidebar-sx', 'before_title' => '<h3>', 'after_title' => '</h3>', 'before_widget' => '', 'after_widget' => '', )); if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'Sidebar-dx', 'before_title' => '<h3>', 'after_title' => '</h3>', 'before_widget' => '', 'after_widget' => '', )); if ( function_exists('register_sidebar') ) register_sidebar(array( 'name' => 'advertisement', 'before_title' => '<h3 class="hide2">', 'after_title' => '</h3>', 'before_widget' => '', 'after_widget' => '', )); //various theme support add_theme_support( 'automatic-feed-links' ); add_theme_support( 'post-thumbnails' ); add_theme_support( 'post-formats', array( 'aside', // title less blurb 'gallery', // gallery of images 'link', // quick link to other site 'image', // an image 'quote', // a quick quote 'status', // a Facebook like status update 'video', // video 'audio', // audio 'chat' // chat transcript ) ); //microformati add_theme_support( 'structured-post-formats', array( 'link', 'video' ) ); //custom thumbnail size add_image_size( 'thumb-600', 600, 150, true ); add_image_size( 'thumb-300', 300, 100, true ); //call in theme : <?php the_post_thumbnail( 'thumb-300' ); ?> //see more on: http://codex.wordpress.org/Function_Reference/add_image_size //navigation menu add_theme_support( 'menus' ); if (function_exists('register_nav_menus')) { register_nav_menus( array( 'main-nav' => __( 'Main Navigation' ), 'footer-nav' => __( 'Footer Navigation'), ) ); } // shortcode in widget add_filter('widget_text', 'do_shortcode'); /* in the theme ... wp_nav_menu(array( 'container' => false, // remove nav container 'container_class' => 'menu clearfix', // class of container (should you choose to use it) 'menu' => __( 'The Main Menu', 'bonestheme' ), // nav name 'menu_class' => 'nav top-nav clearfix', // adding custom nav class 'theme_location' => 'main-nav', // where it's located in the theme 'before' => '', // before the menu 'after' => '', // after the menu 'link_before' => '', // before each link 'link_after' => '', // after each link 'depth' => 0, // limit the depth of the nav 'fallback_cb' => 'bones_main_nav_fallback' // fallback function )); } */ //clean wp-head remove_action( 'wp_head', 'rsd_link' ); // windows live writer remove_action( 'wp_head', 'wlwmanifest_link' ); // index link remove_action( 'wp_head', 'index_rel_link' ); // previous link remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); // start link remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); // links for adjacent posts remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); // WP version remove_action( 'wp_head', 'wp_generator' ); // remove WP version from css // i going to add this // remove injected CSS for recent comments widget // remove injected CSS from recent comments widget // remove injected CSS from gallery // replace jquery if( !is_admin()){ wp_deregister_script('jquery'); wp_register_script('jquery', (/*"http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js*/ "https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"), false, '1.7.1'); wp_enqueue_script('jquery'); } // disable admin bar function disable_admin_bar(){ return false; } add_filter( 'show_admin_bar' , 'disable_admin_bar' ); /// related post function related_posts() { echo '<ul id="related-posts">'; global $post; $tags = wp_get_post_tags($post->ID); if($tags) { foreach($tags as $tag) { $tag_arr .= $tag->slug . ','; } $args = array( 'tag' => $tag_arr, 'numberposts' => 5, /* you can change this to show more */ 'post__not_in' => array($post->ID) ); $related_posts = get_posts($args); if($related_posts) { foreach ($related_posts as $post) : setup_postdata($post); ?> <li class="related_post"><a class="entry-unrelated" href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li> <?php endforeach; } else { ?> <?php } } wp_reset_query(); echo '</ul>'; } }
You need to login to post a comment.