Automatically add Twitter and Facebook buttons to your posts
Posted by The Farmer on Jan 28, 2011 in Wordpress | 1 comment
Paste the code below into your functions.php file, save it, and you’re done. function share_this($content){ if(!is_feed() && !is_home()) { $content .= '<div class="share-this"> <a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal">Tweet</a> <script...
Read MoreHow to show the “home” link on wp_nav_menu default fallback function
Posted by The Farmer on Jan 28, 2011 in Wordpress | 0 comments
You just have to paste the following code into your theme functions.php file: function my_page_menu_args($args) { $args['show_home'] = true; return $args; } add_filter('wp_page_menu_args', 'my_page_menu_args'); Thanks to Reza for this nice piece of code! Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!How to show...
Read MoreHow to automatically add a search field to your navigation menu
Posted by The Farmer on Jan 28, 2011 in Wordpress | 0 comments
Open your functions.php file, and paste the following code. The search field will be displayed once you saved the file. add_filter('wp_nav_menu_items','add_search_box', 10, 2); function add_search_box($items, $args) { ob_start(); get_search_form(); $searchform = ob_get_contents(); ob_end_clean(); $items .= '<li>' ....
Read MoreWordPress tip: Remove WP 3.1 Admin Bar
Posted by The Farmer on Jan 28, 2011 in Wordpress | 0 comments
Simply paste the following line of code on your functions.php file: remove_action('init', 'wp_admin_bar_init'); Once the file is saved, the Admin Bar will not be displayed again. Thanks to Yoast for the tip! Looking for WordPress hosting? Try WP Web Host. Prices starts at $5/month and you can try it for free!WordPress tip: Remove WP 3.1 Admin...
Read MoreWordPress trick: Get category slug using category ID
Posted by The Farmer on Jan 28, 2011 in Wordpress | 0 comments
First, put the following function in your functions.php file: function get_cat_slug($cat_id) { $cat_id = (int) $cat_id; $category = &get_category($cat_id); return $category->slug; } Once done, you can call the function as shown below: <?php echo get_cat_slug(3); ?> This will display the slug for the category with the ID 3. Thanks to Ken Rosaka for the tip! Looking for WordPress...
Read More






