Skip to content

Instantly share code, notes, and snippets.

View stuartduff's full-sized avatar

Stuart Duff stuartduff

View GitHub Profile
@stuartduff
stuartduff / gist:11402159
Created April 29, 2014 14:32
woo_blog_template_query_args
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 June 3, 2014 14:00
Move Superstore WooCommerce Single Page Description
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 );
@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%;
@stuartduff
stuartduff / gist:f330aaf4f6358f898f24
Created July 15, 2014 18:03
FireFox Input Field Fix
input.qty {
-moz-appearance: textfield; /* Hide buttons for Firefox 29 and later */
}
@stuartduff
stuartduff / gist:23e4c543153e27a27573
Last active August 29, 2015 14:04
Projects Posts Per Page
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:9579eebf6bc542e20ee5
Created March 18, 2015 12:10
Projects Randomise Project Archive & Category Output
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 / gist:8d9c59c8a0e61f4c2ebe
Created March 18, 2015 13:25
The Theme Foundry - Make Theme Sensei Wrappers
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 / wordpress-login-redirect.php
Created July 22, 2015 20:26
Adding this snippet to the functions.php of your wordpress theme will redirect visitors to the page they were viewing after logging in.
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 / woocommerce-exclude-on-sale-products.php
Last active August 29, 2015 14:25
This snippet will exclude the on sale products from the WooCommerce loop
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 / sf-tag-comma-remove
Created August 6, 2015 17:53
Removes the comma from tags in storefront
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() ) : ?>