Skip to content

Instantly share code, notes, and snippets.

View srikat's full-sized avatar

Sridhar Katakam srikat

View GitHub Profile
@srikat
srikat / functions1.php
Last active June 1, 2016 00:26
How to enable Author Box on single entries of 'post' type only. https://sridharkatakam.com/enable-author-box-single-entries-post-type-genesis/
//* Display author box on single posts
add_filter( 'get_the_author_genesis_author_box_single', '__return_true' );
@srikat
srikat / functions.php
Last active April 23, 2019 07:08
Force a layout for Pages that have subpages in Genesis. https://sridharkatakam.com/force-layout-pages-subpages-genesis/
// Apply layout to static Pages that have children (subpages)
add_action( 'get_header', 'sk_force_layout' );
function sk_force_layout() {
global $post;
// if we are on a static Page and if it does not have a parent
if ( is_singular( 'page' ) && !$post->post_parent ) {
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' );
}
<?php
add_action( 'genesis_loop', 'sk_do_loop' );
/**
* Outputs a custom loop
*
* @global mixed $paged current page number if paginated
* @return void
*/
function sk_do_loop() {
@srikat
srikat / functions.php
Last active May 24, 2016 03:48
How to show books in ascending order of published date when using Genesis Author Pro plugin. https://sridharkatakam.com/show-series-tags-books-library-using-genesis-author-pro-plugin/
add_action( 'pre_get_posts', 'sk_change_books_order' );
/**
* Change display order of books on the archive from DESC to ASC
*
* @author Bill Erickson
* @link http://www.billerickson.net/customize-the-wordpress-query/
* @param object $query data
*
*/
function sk_change_books_order( $query ) {
@srikat
srikat / functions.php
Last active October 29, 2016 01:00
How to automatically add browser class to html in WordPress. https://sridharkatakam.com/automatically-add-browser-class-html-wordpress/
// Enqueue Scripts
add_action( 'wp_enqueue_scripts', 'sk_enqueue_scripts' );
function sk_enqueue_scripts() {
wp_enqueue_script( 'detect', get_stylesheet_directory_uri() . '/js/detect.min.js', '', '1.0.0', true );
wp_enqueue_script( 'general', get_stylesheet_directory_uri() . '/js/general.js', '', '1.0.0', true );
}
// Load Flexbox Grid
add_action( 'wp_enqueue_scripts', 'sk_enqueue_flexbox_grid' );
function sk_enqueue_flexbox_grid() {
wp_enqueue_style( 'flexboxgrid', CHILD_URL . '/css/flexboxgrid.min.css' );
}
// Customize entry meta in the entry header to show Favorite button for logged in users and Favorites count for non logged in users
add_filter( 'genesis_post_info', 'sk_post_info_filter' );
function sk_post_info_filter( $post_info ) {
if ( is_user_logged_in() ) {
$post_info = '[post_date] by [post_author_posts_link] [post_comments] [post_edit] [favorite_button]';
} else {
$post_info = '[post_date] by [post_author_posts_link] [post_comments] [post_edit] <span class="favorite-count">Favorited: [favorite_count] times</a>';
}
@srikat
srikat / functions.php
Last active April 12, 2016 23:34
How to display custom fields above other widgets of sidebar in Genesis. https://sridharkatakam.com/display-custom-fields-widgets-sidebar-genesis/
// Display values of custom fields at the top of Primary Sidebar on event CPT singular pages
add_action( 'genesis_before_sidebar_widget_area', 'sk_single_event_custom_fields' );
function sk_single_event_custom_fields() {
// if we are not on a single event page, abort.
if ( !is_singular( 'event' ) ) {
return;
}
$event_cost = get_post_meta( get_the_ID(), 'event_cost', true );
@srikat
srikat / functions.php
Last active July 20, 2021 18:11
How to set up smooth scrolling for hash links in WordPress. https://sridharkatakam.com/set-smooth-scrolling-hash-links/
// Enqueue site-wide scripts
add_action( 'wp_enqueue_scripts', 'sk_enqueue_scripts' );
function sk_enqueue_scripts() {
wp_enqueue_script( 'global', get_stylesheet_directory_uri() . '/js/global.js', array( 'jquery' ), '', true );
}
@srikat
srikat / functions1.php
Last active October 29, 2016 01:03
How to enclose Headline and Intro Text on archive pages in a wrap in Genesis. https://sridharkatakam.com/enclose-headline-intro-text-wrap-archive-pages-genesis/
remove_action( 'genesis_before_loop', 'genesis_do_taxonomy_title_description', 15 );
add_action( 'genesis_after_header', 'genesis_do_taxonomy_title_description' );