Skip to content

Instantly share code, notes, and snippets.

View stuartduff's full-sized avatar

Stuart Duff stuartduff

View GitHub Profile
@stuartduff
stuartduff / woo canvas slider height fix
Created July 17, 2012 11:00
Woo Canvas Slider Height Fix
.magazine #loopedSlider li.slide img { height: 300px !important; }
#loopedSlider .slides { top:0; left:0; overflow: hidden; position:relative; }
@stuartduff
stuartduff / woo-biz-slider-portfolio.php
Created July 18, 2012 16:06
Woo Business Slider Canvas Portfolio Page
// Display the "Business" slider above the default WordPress homepage.
add_action( 'get_header', 'woo_custom_load_biz_slider', 10 );
function woo_custom_load_biz_slider () {
if ( is_page('portfolio') ) {
add_action( 'woo_content_before', 'woo_slider_biz', 10 );
add_action( 'woo_content_before', 'woo_custom_reset_biz_query', 11 );
add_action( 'woo_load_slider_js', '__return_true', 10 );
add_filter( 'body_class', 'woo_custom_add_business_bodyclass', 10 );
}
@stuartduff
stuartduff / gist:3137466
Created July 18, 2012 17:00
Woo FlipFlop categoriies grid on posts
add_action( 'woo_content_before', 'categories_grid', 10 );
function categories_grid() {
if ( is_singular('post') ) {
echo '<section id="main" class="fullwidth">';
get_template_part( 'includes/categories-grid' );
echo '</section>';
}
@stuartduff
stuartduff / backgroundall.php
Created July 18, 2012 22:24
Unsigned Background Slides Across All Pages
<?php
if ( $settings['enable_slides'] == 'true' ) {
// Load the slider background images.
get_template_part( 'includes/slider', 'background' );
}
?>
@stuartduff
stuartduff / wpremovesubpages.php
Created July 19, 2012 10:37
WordPress remove sub pages of a parent page
<?php
$child_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_parent = 134 AND $wpdb->posts.post_type = 'page' AND $wpdb->posts.post_status = 'publish' ORDER BY $wpdb->posts.ID ASC");
$exclude = implode($child_ids,', ');
wp_list_pages('exclude=' . $exclude . '&title_li=');
?>
@stuartduff
stuartduff / translate.php
Last active July 17, 2022 14:34
WordPress Translate Text testing Snippet - this snippet when added to a themes functions.php file will let you test if the Localization of a word or text string is taking effect and changing within a theme or plugin without using the translation .MO and .PO files.
function translate_text( $translated ) {
// The first parameter is the original text, the second parameter is the changed text.
$translated = str_ireplace( 'Choose and option', 'Select', $translated );
// Returns the translated text
return $translated;
}
add_filter( 'gettext', 'translate_text' );
@stuartduff
stuartduff / wc-fullwidth.css
Created July 20, 2012 14:07
WooCommerce Single Product Page Full Width
body.single-product #sidebar {display:none;}
body.single-product #main.col-left {width:100%}
@stuartduff
stuartduff / default-avatar.php
Created July 24, 2012 01:18
WordPress Default Custom Avatar
if ( !function_exists('custom_gravatars') ) {
function custom_gravatars( $avatar_defaults ) {
$myavatar = get_template_directory_uri() . '/images/custom-avatar.png';
$avatar_defaults[$myavatar] = 'people';
return $avatar_defaults;
}
add_filter( 'avatar_defaults', 'custom_gravatars' );
}
@stuartduff
stuartduff / wp-archive-url.php
Created July 26, 2012 16:09
WordPress Get Logged In User Author Archive URL
function loggedin_user_archive() {
global $current_user;
get_currentuserinfo();
if ( is_user_logged_in() ) {
echo '<a href="' . site_url() . '/author/' . $current_user->display_name . '/">'. $current_user->display_name .' Archives</a>';
}
}
@stuartduff
stuartduff / github-wppembed.php
Created July 28, 2012 15:04
Easily embed and share Github gists on your WordPress blog
**
* Usage:
* Paste a gist link into a blog post or page and it will be embedded eg:
* https://gist.github.com/2926827
*
* If a gist has multiple files you can select one using a url in the following format:
* https://gist.github.com/2926827?file=embed-gist.php
*/
wp_embed_register_handler( 'gist', '/https:\/\/gist\.github\.com\/(\d+)(\?file=.*)?/i', 'wp_embed_handler_gist' );