Skip to content

Instantly share code, notes, and snippets.

View srikat's full-sized avatar

Sridhar Katakam srikat

View GitHub Profile
@srikat
srikat / test.html
Created May 8, 2018 06:48
Dummy Content for Gutenberg
<!-- wp:heading -->
<h2>Heading Block (H2)</h2>
<!-- /wp:heading -->
<!-- wp:heading -->
<h3>You are looking at one. (H3)</h3>
<!-- /wp:heading -->
<!-- wp:heading -->
<h2>Subhead Block</h2>
<?php
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'sk_show_subcategories_do_loop' );
/**
* Displays a list of linked child categories on category pages
*
*/
function sk_show_subcategories_do_loop() {
@srikat
srikat / functions.php
Last active November 13, 2019 17:28
How to use WordPress Customizer for setting up Background Image of a section in Genesis. https://sridharkatakam.com/how-to-use-wordpress-customizer-for-setting-up-background-image-of-a-section-in-genesis/
/**
* Theme Options Customizer Implementation.
*
* @link http://ottopress.com/2012/how-to-leverage-the-theme-customizer-in-your-own-themes/
*
* @param WP_Customize_Manager $wp_customize Object that holds the customizer data.
*/
function sk_register_theme_customizer( $wp_customize ){
/*
<?php
//* Do NOT include the opening php tag
//* Enqueue Animate.CSS and WOW.js
add_action( 'wp_enqueue_scripts', 'sk_enqueue_scripts' );
function sk_enqueue_scripts() {
wp_enqueue_style( 'animate', get_stylesheet_directory_uri() . '/css/animate.min.css' );
wp_enqueue_script( 'wow', get_stylesheet_directory_uri() . '/js/wow.min.js', array(), '', true );
@srikat
srikat / functions.php
Last active October 13, 2019 23:49
Remove "Select options" button from (variable) products on the main WooCommerce shop page. https://sridharkatakam.com/remove-select-options-button-variable-products-main-woocommerce-shop-page/
// Remove "Select options" button from (variable) products on the main WooCommerce shop page.
add_filter( 'woocommerce_loop_add_to_cart_link', function( $product ) {
global $product;
if ( is_shop() && 'variable' === $product->product_type ) {
return '';
} else {
sprintf( '<a href="%s" data-quantity="%s" class="%s" %s>%s</a>',
esc_url( $product->add_to_cart_url() ),
@srikat
srikat / functions.php
Last active September 29, 2019 07:53
How to use Customizer API to add settings for Header background color and background image in Genesis. https://sridharkatakam.com/how-to-use-customizer-api-to-add-settings-for-header-background-color-and-background-image-in-genesis/
/**
* HEX Color sanitization callback.
*
* - Sanitization: hex_color
* - Control: text, WP_Customize_Color_Control
*
* Note: sanitize_hex_color_no_hash() can also be used here, depending on whether
* or not the hash prefix should be stored/retrieved with the hex color value.
*
* @see sanitize_hex_color() https://developer.wordpress.org/reference/functions/sanitize_hex_color/
/* Sticky header */
.site-header {
position: fixed;
width: 100%;
z-index: 1000;
}
nav.nav-primary {
padding-top: 164px; /*height of header (can be easily obtained using Firebug)*/
@srikat
srikat / sticky-menu.js
Last active August 25, 2019 13:02
Fixed nav menu which appears upon scrolling in News Pro. http://sridharkatakam.com/set-fixed-nav-menu-appears-upon-scrolling-news-pro/
//* Add support for structural wraps
add_theme_support( 'genesis-structural-wraps', array(
'header',
'site-tagline',
'nav',
'subnav',
'home-featured',
'site-inner',
'footer-widgets',
'footer',
@srikat
srikat / functions.php
Created January 10, 2014 05:32
Add Post categories above Post titles and display only Post tags in entry footer in Genesis. Scope: Single Posts, Search results page, static Pages to which 'Blog' Page Template is applied. Context: http://sridharkatakam.com/moving-post-categories-entry-meta-post-title-genesis/#comment-2309
add_action( 'template_redirect', 'sk_categories_above_titles' );
function sk_categories_above_titles() {
if ( ! ( is_singular('post') || is_archive() || is_search() || is_page_template('page_blog.php' ) ) )
return;
add_action ( 'genesis_entry_header', 'sk_show_category_names', 9 );
add_filter( 'genesis_post_meta', 'sk_post_meta_filter' );
}
@srikat
srikat / functions.php
Last active June 17, 2019 13:48
How to remove Post Meta from Entry Footer in Genesis.
add_action( 'genesis_entry_content', 'sk_remove_post_meta' );
/**
* Remove Post Meta in Entry Footer site-wide excerpt on static Pages.
*
* @author Sridhar Katakam
* @link http://sridharkatakam.com/remove-post-meta-entry-footer-genesis/
*/
function sk_remove_post_meta() {
if ( is_singular( 'page' ) ) {
return;