Skip to content

Instantly share code, notes, and snippets.

Aron Baczoni baczoni

Block or report user

Report or block baczoni

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@baczoni
baczoni / gist:2481130
Created Apr 24, 2012
Wordpress: Add searchbox to nav menu
View gist:2481130
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:2481083
Created Apr 24, 2012
Wordpress: Disable self trackbacks
View gist:2481083
function disable_self_ping( &$links ) {
foreach ( $links as $l => $link )
if ( 0 === strpos( $link, get_option( 'home' ) ) )
unset($links[$l]);
}
add_action( 'pre_ping', 'disable_self_ping' );
@baczoni
baczoni / gist:2481075
Created Apr 24, 2012
Wordpress: Remove 'Read more' jump
View gist:2481075
function wdc_no_more_jumping($post) {
return '<a href="'.get_permalink($post->ID).'" class="read-more">'.'Continue Reading'.'</a>';
}
add_filter('excerpt_more', 'wdc_no_more_jumping');
@baczoni
baczoni / gist:2481067
Created Apr 24, 2012
Wordpress: Display latest Google+ post
View gist:2481067
<?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:2481027
Created Apr 24, 2012
Wordpress: Display custom RSS feed
View gist:2481027
<?php include_once(ABSPATH.WPINC.'/rss.php');
wp_rss('http://wpforums.com/external.php?type=RSS2', 5); ?>
@baczoni
baczoni / gist:2481000
Created Apr 24, 2012
Wordpress: Use schortcodes in widgets
View gist:2481000
<?php add_filter('widget_text', 'do_shortcode') ?>
@baczoni
baczoni / gist:2480989
Created Apr 24, 2012
Wordpress: Additional post classes
View gist:2480989
<?php
function additional_post_classes( $classes ) {
global $wp_query;
if( $wp_query->found_posts < 1 ) {
return $classes;
}
if( $wp_query->current_post == 0 ) {
$classes[] = 'post-first';
@baczoni
baczoni / gist:2480964
Created Apr 24, 2012
Wordpress: Enable excerpt for pages
View gist:2480964
<?php
function my_init() {
add_post_type_support('page', array('excerpt'));
}
add_action('init', 'my_init');
?>
@baczoni
baczoni / gist:2480946
Created Apr 24, 2012
Wordpress: Enable featured image for posts/pages
View gist:2480946
<?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:2480899
Created Apr 24, 2012
Wordpress: Separate comments from trackbacks
View gist:2480899
<?php
// Find:
foreach ($comments as $comment) :
// Comments are displayed here
endforeach;
?>
<?php
// And replace with:
?>
You can’t perform that action at this time.