Skip to content

Instantly share code, notes, and snippets.

Sridhar Katakam srikat

View GitHub Profile
yankiara / oxygen-repeater-dynamic-query.php
Last active Jun 20, 2020
Use dynamic queries with Oxygen's repeater
View oxygen-repeater-dynamic-query.php
* Example of related posts repeater for any CPT with taxonomy:
* - Filter query to prevent altering queries inside the repeater items,
* - Retrieve post category slug : I have only one for each post, so I just take first element.
* (You might need to add error tests, of course, if you don't accept empty results,
* for instance if you forgot to set post category.)
* - Set tax_query arg with category slug
* - Set random order
* - Exclude current post
* - Deactivate pagination
badabingbreda / oxygenbuilder2_manage_edit_column_apply_to.php
Last active Jul 16, 2018
Oxygenbuilder2 Template overview Add Column "Apply To" and "In Use"
View oxygenbuilder2_manage_edit_column_apply_to.php
* Add a apply_to and in_use column to Oxygenbuilder2.0's ct_templates overview.
* It will:
* - tell you the rules on the templates
* - show you if a re-usable is being used on a post/page/cpt so if not, you can safely delete it.
add_filter('manage_edit-ct_template_columns', 'add_new_ct_template_columns');
robincornett / functions.php
Created Oct 31, 2017
Code to remove landing pages from site search results. Assumes that templates are in the templates directory inside the theme.
View functions.php
add_action( 'pre_get_posts', 'leaven_search_hide_landing_page' );
* Remove landing pages from the search results.
* @param $query \WP_Query
* @return mixed
timothyjensen / functions.php
Last active Feb 5, 2018
Get an auto generated post excerpt, or a manual excerpt if one has been set.
View functions.php
// Make sure to prefix the function if you do not use a namespace.
// namespace TimJensen\HelperFunctions;
* Returns an auto generated post excerpt, or a manual excerpt if one has been set.
* @version 1.2.1
* @param int $post_id Required. Post ID.
ohiosveryown / change-class-on-scroll.html
Last active Jul 27, 2020
Vanilla JS – change/add class based on scroll position.
View change-class-on-scroll.html
// layout
// style
body { min-height: 200vh; }
nav {
bradpotter / functions.php
Last active Aug 29, 2015
Register a sidebar for a page that has a page template selected
View functions.php
add_action('widgets_init', 'gpb_register_sidebar');
* Dynamically register sidebar for pages that use specified template
function gpb_register_sidebar() {
global $post;
global $wp_registered_sidebars;
// Find all pages that use template with dynamic sidebar
View display-gallery-as-soliloquy-dynamic-slider.php
calliaweb / filter-genesis-structural-wrap.php
Last active Sep 15, 2016
Filter Genesis Structural Wrap
View filter-genesis-structural-wrap.php
//* Do NOT include the opening php tag
add_filter( "genesis_structural_wrap-footer-widgets", 'jmw_filter_footer_widgets_structural_wrap', 10, 2);
* Filter the footer-widgets context of the genesis_structural_wrap to add a div before the closing wrap div.
* @param string $output The markup to be returned
* @param string $original_output Set to either 'open' or 'close'
robincornett / functions.php
Last active Aug 27, 2018
optional home.php--to show the posts (blog) page's title and content
View functions.php
// do NOT include the opening line! Just add what's below to the end of your functions.php file
add_action( 'edit_form_after_title', 'rgc_posts_page_edit_form' );
function rgc_posts_page_edit_form( $post ) {
$posts_page = (int) get_option( 'page_for_posts' );
if ( $posts_page === $post->ID ) {
add_post_type_support( 'page', 'editor' );
robneu / genesis-nav-space-fix.css
Last active May 21, 2018
Remove unwated space from nav elements on Genesis themes.
View genesis-nav-space-fix.css
* The Default Genesis styles have a bug which causes extra unwanted
* space to display in the nav menu bar elements. This will remove the
* extra space cross-browser. The reason for the strange .001px font size
* is due to a bug on older Andorid devices.
* Note: I've used the default Genesis styles here as an example. The only
* actual change is the font-size rule on both selectors.
* Reference link:
You can’t perform that action at this time.