Skip to content

Instantly share code, notes, and snippets.

View baczoni's full-sized avatar

Aron Baczoni baczoni

View GitHub Profile
@baczoni
baczoni / gist:2480550
Created April 24, 2012 15:20
Wordpress: Limit or remove revisions
** Add to wp-config.php file **
<?php
# Maximum 5 revisions #
define('WP_POST_REVISIONS', 5);
# Disable revisions #
define('WP_POST_REVISIONS', false);
?>
@baczoni
baczoni / gist:2480866
Created April 24, 2012 15:45
Wordpress: Create widget areas
//Create widget areas
<?php
// In functions.php
register_sidebar(array(
'name' => 'Sidebar',
'id' => 'sidebar',
'before_widget' => '<li>',
'after_widget' => '</li>',
'before_title' => '<h3>',
@baczoni
baczoni / gist:2481067
Created April 24, 2012 16:09
Wordpress: Display latest Google+ post
<?php
include_once(ABSPATH.WPINC.'/rss.php');
$googleplus = fetch_feed("http://plusfeed.appspot.com/123456789..."); // Replace 123456789... by your own ID
echo '<a href="';
echo $googleplus->items[0]['link']; echo '">';
echo $googleplus->items[0]['summary'];
echo '';
?>
@baczoni
baczoni / gist:2480609
Created April 24, 2012 15:27
Wordpress: Custom admin logo
//Custom admin logo - 30px wide, 31px high transparent gif. Header background color: #464646
add_action('admin_head', 'my_custom_logo');
function my_custom_logo() {
echo '
<style type="text/css">
#header-logo { background-image: url('.get_bloginfo('template_directory').'/images/custom-logo.gif) !important; }
</style>
';
}
@baczoni
baczoni / gist:2480946
Created April 24, 2012 15:53
Wordpress: Enable featured image for posts/pages
<?php
add_theme_support( 'post-thumbnails' );
// This adds support for pages only:
add_theme_support( 'post-thumbnails', array( 'page' ) );
// And this adds support for posts only:
add_theme_support( 'post-thumbnails', array( 'post' ) );
@baczoni
baczoni / gist:2480484
Created April 24, 2012 15:14
Wordpress: Create page template
<?php
/*
Template Name: Name of your Template
*/
?>
@baczoni
baczoni / gist:2481000
Created April 24, 2012 16:00
Wordpress: Use schortcodes in widgets
<?php add_filter('widget_text', 'do_shortcode') ?>
@baczoni
baczoni / gist:2481027
Created April 24, 2012 16:04
Wordpress: Display custom RSS feed
<?php include_once(ABSPATH.WPINC.'/rss.php');
wp_rss('http://wpforums.com/external.php?type=RSS2', 5); ?>
@baczoni
baczoni / gist:2481130
Created April 24, 2012 16:17
Wordpress: Add searchbox to nav menu
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>' . $searchform . '</li>';
return $items;
}
@baczoni
baczoni / gist:2480638
Created April 24, 2012 15:30
Wordpress: Change admin footer text
<?php
function remove_footer_admin () {
echo 'My footer text. Thank you <a href="http://wordpress.org">Wordpress</a> for giving me this filter.';
}
add_filter('admin_footer_text', 'remove_footer_admin');
?>