Posted By

xma on 05/06/13


Tagged

worpdressfunctions


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

xma
zemonte


wordpress functions


 / Published in: PHP
 

URL: xmawpfunc

function files for worpdress

  1. //when theme fire up...
  2.  
  3. add_action('after_setup_theme','themeoptions', 16);
  4.  
  5. function themeoptions(){
  6.  
  7. //include additional filesĀ 
  8. require_once(TEMPLATEPATH . '/theme/themeoptions.php');
  9.  
  10. load_theme_textdomain( 'mytheme', TEMPLATEPATH.'/languages' );
  11.  
  12.  
  13. // Excerpt more e title post cut
  14.  
  15. function new_excerpt_more( $more ) {
  16. global $post;
  17. return ' <a class="moretag" href="'. get_permalink($post->ID) . '"> ' . __( 'Read more', 'mytheme' ) . '...</a> ';
  18. }
  19. add_filter('excerpt_more', 'new_excerpt_more');
  20. function excerpt_length($length) {
  21. return 60;
  22. }
  23.  
  24. add_filter('excerpt_length', 'excerpt_length');
  25.  
  26. function snip_title($limit) {
  27. global $post;
  28. $title = get_the_title($post->ID);
  29. if (strlen($title) > $limit){
  30. $title = substr($title, 0, $limit) . '...';
  31. echo $title;
  32. }else{
  33. echo $title;
  34. }
  35. }
  36.  
  37.  
  38. //sidebar widget
  39.  
  40. if ( function_exists('register_sidebar') )
  41. register_sidebar(array(
  42. 'name' => 'Sidebar-sx',
  43. 'before_title' => '<h3>',
  44. 'after_title' => '</h3>',
  45. 'before_widget' => '',
  46. 'after_widget' => '',
  47. ));
  48.  
  49. if ( function_exists('register_sidebar') )
  50. register_sidebar(array(
  51. 'name' => 'Sidebar-dx',
  52. 'before_title' => '<h3>',
  53. 'after_title' => '</h3>',
  54. 'before_widget' => '',
  55. 'after_widget' => '',
  56. ));
  57.  
  58. if ( function_exists('register_sidebar') )
  59. register_sidebar(array(
  60. 'name' => 'advertisement',
  61. 'before_title' => '<h3 class="hide2">',
  62. 'after_title' => '</h3>',
  63. 'before_widget' => '',
  64. 'after_widget' => '',
  65. ));
  66.  
  67. //various theme support
  68.  
  69. add_theme_support( 'automatic-feed-links' );
  70. add_theme_support( 'post-thumbnails' );
  71. add_theme_support( 'post-formats',
  72. array(
  73. 'aside', // title less blurb
  74. 'gallery', // gallery of images
  75. 'link', // quick link to other site
  76. 'image', // an image
  77. 'quote', // a quick quote
  78. 'status', // a Facebook like status update
  79. 'video', // video
  80. 'audio', // audio
  81. 'chat' // chat transcript
  82. )
  83. );
  84. //microformati
  85. add_theme_support( 'structured-post-formats', array( 'link', 'video' ) );
  86.  
  87. //custom thumbnail size
  88. add_image_size( 'thumb-600', 600, 150, true );
  89. add_image_size( 'thumb-300', 300, 100, true );
  90.  
  91. //call in theme : <?php the_post_thumbnail( 'thumb-300' ); ?>
  92. //see more on: http://codex.wordpress.org/Function_Reference/add_image_size
  93.  
  94. //navigation menu
  95. add_theme_support( 'menus' );
  96.  
  97. if (function_exists('register_nav_menus')) {
  98. register_nav_menus( array(
  99. 'main-nav' => __( 'Main Navigation' ),
  100. 'footer-nav' => __( 'Footer Navigation'),
  101. ) );
  102. }
  103.  
  104. // shortcode in widget
  105.  
  106. add_filter('widget_text', 'do_shortcode');
  107.  
  108. /* in the theme ...
  109. wp_nav_menu(array(
  110. 'container' => false, // remove nav container
  111. 'container_class' => 'menu clearfix', // class of container (should you choose to use it)
  112. 'menu' => __( 'The Main Menu', 'bonestheme' ), // nav name
  113. 'menu_class' => 'nav top-nav clearfix', // adding custom nav class
  114. 'theme_location' => 'main-nav', // where it's located in the theme
  115. 'before' => '', // before the menu
  116. 'after' => '', // after the menu
  117. 'link_before' => '', // before each link
  118. 'link_after' => '', // after each link
  119. 'depth' => 0, // limit the depth of the nav
  120. 'fallback_cb' => 'bones_main_nav_fallback' // fallback function
  121. ));
  122. } */
  123.  
  124.  
  125. //clean wp-head
  126. remove_action( 'wp_head', 'rsd_link' );
  127. // windows live writer
  128. remove_action( 'wp_head', 'wlwmanifest_link' );
  129. // index link
  130. remove_action( 'wp_head', 'index_rel_link' );
  131. // previous link
  132. remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 );
  133. // start link
  134. remove_action( 'wp_head', 'start_post_rel_link', 10, 0 );
  135. // links for adjacent posts
  136. remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
  137. // WP version
  138. remove_action( 'wp_head', 'wp_generator' );
  139. // remove WP version from css
  140. // i going to add this
  141. // remove injected CSS for recent comments widget
  142. // remove injected CSS from recent comments widget
  143. // remove injected CSS from gallery
  144.  
  145. // replace jquery
  146.  
  147. if( !is_admin()){
  148. wp_deregister_script('jquery');
  149. 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');
  150. wp_enqueue_script('jquery');
  151. }
  152. // disable admin bar
  153.  
  154. function disable_admin_bar(){
  155. return false;
  156. }
  157. add_filter( 'show_admin_bar' , 'disable_admin_bar' );
  158.  
  159.  
  160. /// related post
  161. function related_posts() {
  162. echo '<ul id="related-posts">';
  163. global $post;
  164. $tags = wp_get_post_tags($post->ID);
  165. if($tags) {
  166. foreach($tags as $tag) { $tag_arr .= $tag->slug . ','; }
  167. $args = array(
  168. 'tag' => $tag_arr,
  169. 'numberposts' => 5, /* you can change this to show more */
  170. 'post__not_in' => array($post->ID)
  171. );
  172. $related_posts = get_posts($args);
  173. if($related_posts) {
  174. foreach ($related_posts as $post) : setup_postdata($post); ?>
  175. <li class="related_post"><a class="entry-unrelated" href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
  176. <?php endforeach; }
  177. else { ?>
  178. <?php echo '<li class="no_related_post">' . __( 'No Related Posts Yet!', '' ) . '</li>'; ?>
  179. <?php }
  180. }
  181. wp_reset_query();
  182. echo '</ul>';
  183. }
  184.  
  185.  
  186. }

Report this snippet  

You need to login to post a comment.