Skip to content

Instantly share code, notes, and snippets.

View srikat's full-sized avatar

Sridhar Katakam srikat

View GitHub Profile
@srikat
srikat / functions.php
Last active October 31, 2016 23:28
Horizontal Opt-in Form in Genesis using eNews Extended plugin and Flexbox. https://sridharkatakam.com/horizontal-opt-form-genesis-using-enews-extended-plugin-flexbox/
// Register Horizontal Opt-in widget area
genesis_register_widget_area(
array(
'id' => 'horizontal-opt-in',
'name' => __( 'Horizontal Opt-in', 'my-theme-text-domain' ),
'description' => __( 'This is the horizontal opt-in section.', 'my-theme-text-domain' ),
)
);
// Display Horizontal Opt-in widget area below header
@srikat
srikat / functions.php
Last active April 9, 2019 16:26
Add Content below Title for Posts page inside div.posts-page-description in Genesis. https://sridharkatakam.com/adding-content-title-inside-div-posts-page-description-genesis/
// Bring back the missing editor for Posts page
add_action( 'edit_form_after_title', 'rgc_posts_page_edit_form' );
function rgc_posts_page_edit_form( $post ) {
$posts_page = get_option( 'page_for_posts' );
if ( $posts_page === $post->ID ) {
add_post_type_support( 'page', 'editor' );
}
@srikat
srikat / class-custom-featured-post.php
Last active April 3, 2022 16:29 — forked from GaryJones/readme.md
Custom Featured Posts Widget plugin: Skeleton for amending the output of the Genesis Featured Posts widget. https://sridharkatakam.com/custom-featured-post-widget-plugin/
<?php
/**
* Plugin Name
*
* @package Custom_Featured_Post_Widget
* @author Gary Jones
* @license GPL-2.0+
* @link http://gamajo.com/
* @copyright 2013 Gary Jones, Gamajo Tech
*/
@srikat
srikat / functions.php
Last active August 22, 2016 02:47
Add custom taxonomy term in the singular CPT entry permalinks. Source: http://wordpress.stackexchange.com/a/5313/14380. Below is an example for Portfolio. Before: http://d.pr/i/Wt6r, After: http://d.pr/i/QhHN. Make you save changes at Settings > Permalinks.
add_action( 'init', 'vc_portfolio_init' );
/**
* Register a portfolio post type.
*
* @link http://codex.wordpress.org/Function_Reference/register_post_type
*/
function vc_portfolio_init() {
$labels = array(
'name' => _x( 'Portfolio', 'post type general name', 'your-plugin-textdomain' ),
'singular_name' => _x( 'Portfolio Item', 'post type singular name', 'your-plugin-textdomain' ),
@srikat
srikat / functions.php
Created August 19, 2016 06:18
Change skiplinks heading tag from h2 to h1 in Genesis
remove_action ( 'genesis_before_header', 'genesis_skip_links', 5 );
add_action ( 'genesis_before_header', 'sk_skip_links', 5 );
/**
* Add skiplinks for screen readers and keyboard navigation
*
* @since 2.2.0
*/
function sk_skip_links() {
if ( ! genesis_a11y( 'skip-links' ) ) {
@srikat
srikat / functions.php
Last active April 16, 2019 14:06
How to add Google Tag Manager code in Genesis. https://sridharkatakam.com/add-google-tag-manager-code-genesis/
// Add Google Tag Manager code in <head>
add_action( 'wp_head', 'sk_google_tag_manager1' );
function sk_google_tag_manager1() { ?>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXX');</script>
<!-- End Google Tag Manager -->
@srikat
srikat / functions.php
Last active February 15, 2017 01:40
Make BuddyPress Members page obey its Page layout setting in Genesis. https://sridharkatakam.com/make-buddypress-members-page-obey-page-layout-setting-genesis/
/**
* Make BuddyPress Members page obey its Page layout setting
*/
add_filter( 'genesis_pre_get_option_site_layout', 'sk_do_members_page_layout' );
function sk_do_members_page_layout( $opt ) {
// if the current page is not the members directory, abort.
if ( ! bp_is_members_directory() ) {
return;
}
@srikat
srikat / functions.php
Last active February 20, 2017 09:28
How to add font icons before navigation menu items in Genesis using Dashicons. http://sridharkatakam.com/add-font-icons-navigation-menu-items-genesis-using-dashicons/
//* Enqueue Dashicons
add_action( 'wp_enqueue_scripts', 'enqueue_dashicons' );
function enqueue_dashicons() {
wp_enqueue_style( 'dashicons' );
}
@srikat
srikat / functions.php
Last active April 9, 2019 16:26
How to add first, last and numbered classes automatically to widgets in WordPress. http://sridharkatakam.com/add-first-last-numbered-classes-automatically-widgets-wordpress/
/**
* Add "first" and "last" CSS classes to dynamic sidebar widgets. Also adds numeric index class for each widget (widget-1, widget-2, etc.)
*/
function widget_first_last_classes( $params ) {
global $my_widget_num; // Global a counter array
$this_id = $params[0]['id']; // Get the id for the current sidebar we're processing
$arr_registered_widgets = wp_get_sidebars_widgets(); // Get an array of ALL registered widgets
if( !$my_widget_num ) {// If the counter array doesn't exist, create it
@srikat
srikat / functions.php
Last active October 29, 2016 00:55
How to move Secondary Navigation below Slider in Outreach Pro. http://sridharkatakam.com/move-secondary-navigation-slider-outreach-pro/
// Remove the secondary navigation menu on front page
add_action( 'genesis_header', 'sk_conditional_secondary_nav' );
function sk_conditional_secondary_nav() {
// if we are not on front page, abort.
if ( !is_front_page() ) {
return;
}
remove_action( 'genesis_after_header', 'genesis_do_subnav' );