Skip to content

Instantly share code, notes, and snippets.

Avatar

Stuart Duff stuartduff

View GitHub Profile
@stuartduff
stuartduff / woo canvas slider height fix
Created Jul 17, 2012
Woo Canvas Slider Height Fix
View 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 Jul 18, 2012
Woo Business Slider Canvas Portfolio Page
View woo-biz-slider-portfolio.php
// 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 Jul 18, 2012
Woo FlipFlop categoriies grid on posts
View gist:3137466
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 Jul 18, 2012
Unsigned Background Slides Across All Pages
View backgroundall.php
<?php
if ( $settings['enable_slides'] == 'true' ) {
// Load the slider background images.
get_template_part( 'includes/slider', 'background' );
}
?>
@stuartduff
stuartduff / wpremovesubpages.php
Created Jul 19, 2012
WordPress remove sub pages of a parent page
View wpremovesubpages.php
<?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 Apr 20, 2021
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.
View translate.php
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 Jul 20, 2012
WooCommerce Single Product Page Full Width
View wc-fullwidth.css
body.single-product #sidebar {display:none;}
body.single-product #main.col-left {width:100%}
@stuartduff
stuartduff / default-avatar.php
Created Jul 24, 2012
WordPress Default Custom Avatar
View default-avatar.php
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 Jul 26, 2012
WordPress Get Logged In User Author Archive URL
View wp-archive-url.php
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 Jul 28, 2012
Easily embed and share Github gists on your WordPress blog
View github-wppembed.php
**
* 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' );