Skip to content

Instantly share code, notes, and snippets.

Avatar

Stuart Duff stuartduff

View GitHub Profile
@stuartduff
stuartduff / gist:11402159
Created Apr 29, 2014
woo_blog_template_query_args
View gist:11402159
add_filter( 'woo_blog_template_query_args', 'blog_exclude_posts' );
function blog_exclude_posts( $args ) {
$args['post_type'] = 'post';
$args['paged'] = $paged;
$args['category_name'] = 'news';
return $args;
@stuartduff
stuartduff / gist:2f7ef362016bb33c0962
Created Jun 3, 2014
Move Superstore WooCommerce Single Page Description
View gist:2f7ef362016bb33c0962
remove_action ('woocommerce_single_product_summary', 'woocommerce_output_product_data_tabs', 34 );
add_action('woocommerce_after_single_product_summary', 'woocommerce_output_product_data_tabs', 10 );
View hub-products-css-fix
@media only screen and (min-width: 768px) {
ul.products li.product {
float: left;
padding: 0;
margin-right: 0;
margin-bottom: 0;
clear: none;
width: 33.33%;
padding-top: 33.33%;
View gist:f330aaf4f6358f898f24
input.qty {
-moz-appearance: textfield; /* Hide buttons for Firefox 29 and later */
}
@stuartduff
stuartduff / gist:23e4c543153e27a27573
Last active Aug 29, 2015
Projects Posts Per Page
View gist:23e4c543153e27a27573
function custom_projects_posts_per_page( $query ) {
if ( is_admin() || ! $query->is_main_query() )
return;
if ( is_post_type_archive( 'project' ) || is_tax( 'project-category' ) ) {
// Display all posts for a custom post type called 'project'
$query->set( 'posts_per_page', -1 );
return;
}
}
add_action( 'pre_get_posts', 'custom_projects_posts_per_page', 1 );
@stuartduff
stuartduff / gist:8d9c59c8a0e61f4c2ebe
Created Mar 18, 2015
The Theme Foundry - Make Theme Sensei Wrappers
View gist:8d9c59c8a0e61f4c2ebe
add_action( 'init', 'init_sensei_hooks' );
function init_sensei_hooks() {
global $woothemes_sensei;
remove_action( 'sensei_before_main_content', array( $woothemes_sensei->frontend, 'sensei_output_content_wrapper' ), 10 );
remove_action( 'sensei_after_main_content', array( $woothemes_sensei->frontend, 'sensei_output_content_wrapper_end' ), 10 );
add_action('sensei_before_main_content', 'my_theme_wrapper_start', 10);
add_action('sensei_after_main_content', 'my_theme_wrapper_end', 10);
@stuartduff
stuartduff / gist:9579eebf6bc542e20ee5
Created Mar 18, 2015
Projects Randomise Project Archive & Category Output
View gist:9579eebf6bc542e20ee5
function custom_projects_randomise_project_output( $query ) {
if ( is_admin() || ! $query->is_main_query() )
return;
if ( is_post_type_archive( 'project' ) || is_tax( 'project-category' ) ) {
$query->set( 'order', 'ASC' );
$query->set( 'orderby', 'rand' );
return;
}
@stuartduff
stuartduff / woocommerce-exclude-on-sale-products.php
Last active Aug 29, 2015
This snippet will exclude the on sale products from the WooCommerce loop
View woocommerce-exclude-on-sale-products.php
function custom_exclude_on_sale_products_from_query( $q ){
if ( $q->is_search() ) return;
if ( ! $q->is_main_query() ) return;
if ( ! $q->is_post_type_archive() ) return;
if ( ! is_admin() ) {
$product_ids_on_sale = wc_get_product_ids_on_sale();
$q->set( 'post__not_in', (array) $product_ids_on_sale );
@stuartduff
stuartduff / wordpress-login-redirect.php
Created Jul 22, 2015
Adding this snippet to the functions.php of your wordpress theme will redirect visitors to the page they were viewing after logging in.
View wordpress-login-redirect.php
if ( ( isset( $_GET['action'] ) && $_GET['action'] != 'logout' ) || ( isset( $_POST['login_location'] ) && ! empty( $_POST['login_location'] ) ) ) {
add_filter('login_redirect', 'my_login_redirect', 10, 3);
function my_login_redirect() {
$location = $_SERVER['HTTP_REFERER'];
wp_safe_redirect( $location );
exit();
}
}
@stuartduff
stuartduff / sf-tag-comma-remove
Created Aug 6, 2015
Removes the comma from tags in storefront
View sf-tag-comma-remove
function storefront_post_meta() {
?>
<aside class="entry-meta">
<?php if ( 'post' == get_post_type() ) : // Hide category and tag text for pages on Search ?>
<?php
/* translators: used between list items, there is a space after the comma */
$categories_list = get_the_category_list( __( ', ', 'storefront' ) );
if ( $categories_list && storefront_categorized_blog() ) : ?>