Skip to content

Instantly share code, notes, and snippets.

View srikat's full-sized avatar

Sridhar Katakam srikat

View GitHub Profile
/**
* AJAX Load More
* @link http://www.billerickson.net/infinite-scroll-in-wordpress
*/
function be_ajax_load_more() {
$args = isset( $_POST['query'] ) ? array_map( 'esc_attr', $_POST['query'] ) : array();
$args['post_type'] = isset( $args['post_type'] ) ? esc_attr( $args['post_type'] ) : 'post';
$args['paged'] = esc_attr( $_POST['page'] );
$args['post_status'] = 'publish';
<?php
add_action( 'genesis_loop', 'sk_custom_loop' );
function sk_custom_loop() {
$themes = array(
'Agency Pro' => 'agency-pro',
'Agentpress Pro' => 'agentpress-pro',
'Altitude Pro' => 'altitude-pro',
'Ambiance Pro' => 'ambiance-pro',
@srikat
srikat / functions.php
Last active April 9, 2019 16:27
How to overlay entry title on featured image in single Posts. https://sridharkatakam.com/overlay-entry-title-featured-image-single-posts/
// Register a custom image size for hero images on single Posts
add_image_size( 'post-image', 1600, 400, true );
add_action( 'genesis_after_header', 'sk_hero_image' );
function sk_hero_image() {
// if we are not on a single Post, abort.
if ( !is_singular( 'post' ) ) {
return;
}
@srikat
srikat / functions.php
Last active July 4, 2016 01:59
How to automatically change slugs to match titles for Soliloquy sliders. https://sridharkatakam.com/automatically-change-slugs-match-titles-soliloquy-sliders/
// Updates slug to match title for Soliloquy sliders
function sk_force_update_slug( $data, $postarr ) {
if ( 'soliloquy' === $postarr['post_type'] && ! in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) {
$data['post_name'] = sanitize_title( $data['post_title'] );
}
return $data;
}
@srikat
srikat / functions1.php
Last active October 29, 2016 00:57
How to set up site title on homepage and logo on inner pages in Altitude Pro. https://sridharkatakam.com/set-site-title-homepage-logo-inner-pages-altitude-pro/
//* Add support for custom header
add_theme_support( 'custom-header', array(
'flex-height' => true,
'width' => 360,
'height' => 76,
'header-selector' => '.site-title a',
'header-text' => false,
) );
@srikat
srikat / functions.php
Last active April 9, 2019 16:27
How to wrap entry titles inside a custom div in Genesis. https://sridharkatakam.com/wrap-entry-titles-inside-custom-div-genesis/
// Add custom opening div for post title
add_action( 'genesis_entry_header', 'sk_do_post_title_before', 7 );
function sk_do_post_title_before() {
echo '<div class="my-entry-title">';
}
// Add custom closing div for post title
add_action( 'genesis_entry_header', 'sk_do_post_title_after' );
function sk_do_post_title_after() {
echo '</div>';
@srikat
srikat / functions.php
Last active March 19, 2019 23:56
Changing the posts per page on first page without breaking pagination in WordPress. https://sridharkatakam.com/changing-posts-per-page-first-page-without-breaking-pagination-wordpress/
add_action( 'pre_get_posts', 'sk_query_offset', 1 );
function sk_query_offset( &$query ) {
// Before anything else, make sure this is the right query...
if ( ! ( $query->is_home() || is_main_query() ) ) {
return;
}
// First, define your desired offset...
$offset = -1;
@srikat
srikat / functions.php
Last active June 5, 2016 01:43
Display author box on author archives incl. paged pages. https://sridharkatakam.com/display-author-box-pages-author-archives-genesis/
remove_action( 'genesis_before_loop', 'genesis_do_author_box_archive', 15 );
add_action( 'genesis_before_loop', 'sk_do_author_box_archive', 15 );
/**
* Add author box to the top of author archive.
*
* If the headline and description are set to display the author box appears underneath them.
*
* @since 1.4.0
*
* @uses genesis_author_box() Echo the author box and its contents.
@srikat
srikat / functions.php
Last active April 16, 2019 14:06
How to add a full width element inside Genesis header. https://sridharkatakam.com/add-full-width-element-inside-genesis-header/
// Remove default header opening markup function
remove_action( 'genesis_header', 'genesis_header_markup_open', 5 );
// Add back header opening markup function w/o the structural wrap
add_action( 'genesis_header', 'sk_header_markup_open', 5 );
function sk_header_markup_open() {
genesis_markup( array(
'html5' => '<header %s>',
'xhtml' => '<div id="header">',
@srikat
srikat / style.css
Last active April 23, 2019 07:08
Subtitles below Titles in Genesis using Visual Subtitle plugin. https://sridharkatakam.com/subtitles-titles-genesis-using-visual-subtitle-plugin/
.subtitle {
display: block;
margin-top: 10px;
}
.breadcrumb .subtitle {
display: none;
}