Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

roose roose

🏠
Working from home
Block or report user

Report or block roose

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
@roose
roose / pagination.php
Created May 29, 2011
WordPress pagination, based on WP-Pagenavi
View pagination.php
<?php
### Function: Page Navigation
function wp_pagination($before = '', $after = '') {
global $wpdb, $wp_query;
if (!is_single()) {
$request = $wp_query->request;
$posts_per_page = intval(get_query_var('posts_per_page'));
$paged = intval(get_query_var('paged'));
$numposts = $wp_query->found_posts;
@roose
roose / russian_comments_number.php
Created May 29, 2011
WordPress, retrieve the amount of comments a post has with russian plural form.
View russian_comments_number.php
<?php
/**
* Retrieve the amount of comments a post has with russian plural form.
*
* @uses apply_filters() Calls the 'get_comments_number' hook on the number of comments
*
* @param int $post_id The Post ID
* @return int The number of comments a post has
*/
@roose
roose / gist:997870
Created May 29, 2011
WordPress search form template
View gist:997870
<form action="<?php bloginfo('url'); ?>" id="searchform" method="get">
<div>
<input type="text" onblur="if (this.value == '') {this.value = 'Search';}" onfocus="if (this.value == 'Search') {this.value = '';}" id="s" name="s" value="Search"/>
<input type="submit" value="" id="ss"/>
</div>
</form>
@roose
roose / gist:997874
Created May 29, 2011
WordPress Sitemap template file
View gist:997874
<?php
/*
Template Name: Sitemap
*/
?>
<?php get_header(); ?>
<div id="content">
<div id="entry">
<div class="post">
@roose
roose / gist:997878
Last active Sep 25, 2015
Disable automatic generated Wordpress headers
View gist:997878
<?php
/**
* Disable automatic generated Wordpress headers
*/
// Disabling XMLRPC
add_filter('xmlrpc_enabled', '__return_false');
// Remove WordPress Admin Bar
remove_action('init', 'wp_admin_bar_init');
@roose
roose / gist:1021488
Created Jun 12, 2011
Wordpress latest tweet
View gist:1021488
<?php
require_once(ABSPATH . 'wp-includes/class-snoopy.php');
$tweet = get_option("lasttweet");
$url = "http://twitter.com/statuses/user_timeline/mr_roose.json?count=20";
if ($tweet['lastcheck'] < ( mktime() - 60 ) ) {
$snoopy = new Snoopy;
$result = $snoopy->fetch($url);
if ($result) {
$twitterdata = json_decode($snoopy->results,true);
@roose
roose / gist:1933030
Created Feb 28, 2012
Excerpt more string & length
View gist:1933030
<?php
function go_excerpt( $more ) {
return '...';
}
add_filter( 'excerpt_more', 'go_excerpt' );
function go_excerpt_length( $length ) {
return 30;
}
add_filter( 'excerpt_length', 'go_excerpt_length' );
@roose
roose / gist:1933115
Created Feb 28, 2012
Change Wordpress login page logo&link
View gist:1933115
<?php
add_action( 'login_head', 'ilc_custom_login');
function ilc_custom_login() {
echo '<style type="text/css">
h1 a { background-image:url('. get_stylesheet_directory_uri() . '/images/logo2.png' . ') !important; margin-bottom: 10px; }
padding: 20px;}
</style>
<script type="text/javascript">window.onload = function(){document.getElementById("login").getElementsByTagName("a")[0].href = "'. home_url() . '";document.getElementById("login").getElementsByTagName("a")[0].title = "Go to site";}</script>';
}
@roose
roose / exclude_thumbnail_from_gallery.php
Created Feb 28, 2012
Exclude post thumbnail from wordpress native gallery
View exclude_thumbnail_from_gallery.php
You can’t perform that action at this time.