Skip to content

Instantly share code, notes, and snippets.

View frankschrijvers's full-sized avatar

WPStudio frankschrijvers

View GitHub Profile
@frankschrijvers
frankschrijvers / functions.php
Last active July 17, 2021 04:12
Add custom sidebar to WooCommerce pages
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Remove default sidebar, add shop sidebar
add_action( 'genesis_before', 'wpstudio_add_woo_sidebar', 20 );
function wpstudio_add_woo_sidebar() {
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
if( is_woocommerce() ) {
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
@frankschrijvers
frankschrijvers / functions.php
Last active February 9, 2016 13:33
Register webshop sidebar
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Register webshop sidebar
genesis_register_sidebar( array(
'id' => 'woo_primary_sidebar',
'name' => __( 'Webshop Sidebar', 'themename' ),
'description' => __( 'This is the WooCommerce webshop sidebar', 'themename' ),
) );
@frankschrijvers
frankschrijvers / functions.php
Last active January 30, 2024 21:24
Add descriptions to navigation items
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Add description to menu items
add_filter( 'walker_nav_menu_start_el', 'wpstudio_add_description', 10, 2 );
function wpstudio_add_description( $item_output, $item ) {
$description = $item->post_content;
if (' ' !== $description ) {
return preg_replace( '/(<a.*)</', '$1' . '<span class="menu-description">' . $description . '</span><', $item_output) ;
@frankschrijvers
frankschrijvers / widget.html
Created January 21, 2016 22:06
Setup widget
<i class="fa fa-tree"></i>
<h4>Nature</h4>
Nam pretium turpis et arcu. Pellentesque auctor neque nec urna. Sed consequat, leo eget bibendum..
@frankschrijvers
frankschrijvers / style.css
Created December 10, 2015 11:10
WooComemrce - Basic styling sold out badge
.soldout {
background: #c7ad7b;
color: #fff;
font-size: 14px;
font-weight: 700;
padding: 6px 12px;
position: absolute;
right: 0;
top: 0;
}
@frankschrijvers
frankschrijvers / functions.php
Last active December 10, 2015 11:13
WooCommerce - Add sold out badge on single product pages
<?php
//* Do NOT include the opening php tag
//* Add sold out badge on single product pages
add_action( 'woocommerce_before_single_product_summary', function() {
global $product;
if ( !$product->is_in_stock() ) {
echo '<span class="soldout">Sold out</span>';
}
@frankschrijvers
frankschrijvers / functions.php
Last active December 10, 2015 11:13
WooCommerce - Add sold out badge on archive pages
<?php
//* Do NOT include the opening php tag
//* Add sold out badge on archive pages
add_action( 'woocommerce_before_shop_loop_item_title', function() {
global $product;
if ( !$product->is_in_stock() ) {
echo '<span class="soldout">Sold out</span>';
}
@frankschrijvers
frankschrijvers / functions.php
Created November 17, 2015 16:22
Remove site description
remove_action( 'genesis_site_description', 'genesis_seo_site_description' );
@frankschrijvers
frankschrijvers / functions.php
Last active November 17, 2015 16:17
Remove site description on all pages except homepage
<?php
//* Do NOT include the opening PHP tag
//* Remove site description on all pages except homepage
add_action('get_header', 'wpstudio_remove_header');
function wpstudio_remove_header() {
if ( !is_front_page() ) {
remove_action( 'genesis_site_description', 'genesis_seo_site_description' );
}
}
@frankschrijvers
frankschrijvers / functions.php
Last active November 17, 2015 19:29
H1 site title only on the frontpage
<?php
//* Do NOT include the opening PHP tag
//* H1 site title only on the frontpage
add_filter('genesis_seo_title', 'wpstudio_site_title' );
function wpstudio_site_title( $title ) {
$custom_title = get_bloginfo( 'name' );
$tag = ( is_home() || is_front_page() ) ? 'h1' : 'p';
$inside = sprintf( '<a href="%s" title="%s">%s</a>', trailingslashit( home_url() ), esc_attr( get_bloginfo( 'name' ) ), $custom_title );
$title = sprintf ( '<%s class="site-title" itemprop="headline">%s</%s>', $tag, $inside, $tag );