Skip to content

Instantly share code, notes, and snippets.

Avatar

Robert O'Rourke roborourke

View GitHub Profile
@roborourke
roborourke / wordpress-menu-and-dropdown.php
Created Jul 19, 2011
Code example for generating a WP menu and dropdown equivalent in sequence
View wordpress-menu-and-dropdown.php
<?php
$header_menu_args = array(
'theme_location' => 'header'
);
wp_nav_menu( $header_menu_args );
dropdown_menu( $header_menu_args );
@roborourke
roborourke / reload-buttons.js
Created Nov 1, 2011
Reloading Facebook like, Google +1 and Twitter share buttons for content loaded via AJAX
View reload-buttons.js
function reload_buttons() {
// facebook buttons
FB.XFBML.parse( document );
// gplus buttons
gapi.plusone.go();
// twitter buttons
twttr.widgets.load();
@roborourke
roborourke / WordPress Sticky Posts
Created Dec 1, 2011
Makes sticky posts in WordPress works out of the box everywhere
View WordPress Sticky Posts
<?php
// stickier stickies
function fix_sticky_posts( $stickies ) {
foreach( $stickies as $sticky )
wp_update_post( array( 'ID' => $sticky, 'menu_order' => -1 ) );
return $stickies;
}
add_filter('pre_update_option_sticky_posts', 'fix_sticky_posts');
View dabblet.css
/**
* Woot!
*/
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height:100%;
@roborourke
roborourke / blog-categories.php
Created Dec 19, 2011
Small plugin to allow choosing of which categories are including in the main blog list.
View blog-categories.php
<?php
/*
Plugin Name: Blog Categories
Description: Adds a list of checkboxes on the reading settings page to explicitly set which categories show up in the main blog listing.
Version: 0.1
Author: Robert O'Rourke
License: GPLv2 or later
*/
@roborourke
roborourke / exclude-categories.php
Created Dec 19, 2011
This plugin lets you exclude categories from the standard blog posts query in WordPress
View exclude-categories.php
<?php
/*
Plugin Name: Exclude Categories
Description: Adds a list of checkboxes on the reading settings page to explicitly exclude categories from the main blog listing.
Version: 0.1
Author: Robert O'Rourke
License: GPLv2 or later
*/
@roborourke
roborourke / wp-stickies.php
Created Jan 17, 2012
Better sticky post handling for WordPress
View wp-stickies.php
<?php
/**
* Fixes sticky post ordering in WordPress anywhere the order is not explicitly defined.
*
* Updates a post's menu order whenever the sticky posts option is updated
*
* Props to Simon Fransson of http://dessibelle.se/ for a bugfix where 'unstickied' posts were not updated
*
* @param Array $stickies An array of post IDs
@roborourke
roborourke / wp-modify-post-type-query.php
Created Jan 30, 2012
Edit the main WordPress query to show items from a custom post type you specify
View wp-modify-post-type-query.php
<?php
// replace 'post' with the id of the post type you want for your main listing
add_action( 'pre_get_posts', 'modify_main_query' );
function modify_main_query( $query ) {
if ( $query !== $wp_the_query || is_admin() )
return $query;
$query->query_vars[ 'post_type' ] = 'post';
@roborourke
roborourke / better-wp-conditional-comments.php
Created May 1, 2012
Enables !IE in wordpress's conditional comments for styles mechanism
View better-wp-conditional-comments.php
<?php
add_filter( 'style_loader_tag', 'style_loader_tag_ccs', 10, 2 );
/**
* Add support for non IE conditional comments
*
* Trac ticket: http://core.trac.wordpress.org/ticket/16118
*
* Usage:
@roborourke
roborourke / wp-style-dropdown.php
Created May 23, 2012
Code by @alisothegeek to enable a styles dropdown in the WP tinymce editor
View wp-style-dropdown.php
<?php
/*
* Custom styles for tiny mce
* HT: http://alisothegeek.com/2011/05/tinymce-styles-dropdown-wordpress-visual-editor/
*/
add_filter( 'mce_buttons_2', 'my_mce_buttons_2' );
function my_mce_buttons_2( $buttons ) {
array_unshift( $buttons, 'styleselect' );
You can’t perform that action at this time.