Skip to content

Instantly share code, notes, and snippets.

View freezvd's full-sized avatar

Valentin Zmaranda freezvd

  • Bucharest, Romania
View GitHub Profile
<?php
/*
* Examples to add custom classes to Genesis WordPress Framework Markup when using HTML5 output
*/
add_action( 'genesis_setup', 'srf_add_cust_classes', 15 ); // Priority 15 ensures it runs after Genesis itself has setup.
function srf_add_cust_classes() {
add_filter( 'genesis_attr_site-inner', 'srf_attr_site_inner' );
add_filter( 'genesis_attr_content-sidebar-wrap', 'srf_attr_content_sidebar_wrap' );
add_filter( 'genesis_attr_content', 'srf_attr_content' );
add_filter( 'genesis_attr_sidebar-primary', 'srf_attr_sidebar_primary' );
@freezvd
freezvd / admin_bar.php
Created April 11, 2015 07:29
Removing Items from admin bar
<?php
/**
* Remove links/menus from the admin bar
*
* Comment out what you want to keep.
*
* @author Vajrasar Goswami ([email protected])
*
* @see https://codex.wordpress.org/Class_Reference/WP_Admin_Bar
@freezvd
freezvd / functions.php
Created April 11, 2015 07:29
Replace Primary Navigation conditionally with other Menu in Genesis (Modified)
<?php //* Do not include opening php tag
/*
Add Conditional of where you want your custom Menu to show (insted of Primary)
*/
add_action( 'genesis_header', 'sk_replace_menu_in_primary' );
function sk_replace_menu_in_primary() {
if( is_page() ) { // Put your conditional here
@freezvd
freezvd / child_cat_archives.php
Created April 11, 2015 07:29
To get child category of parent in archives
<?php
$cat = get_query_var('cat');
$category = get_category ($cat);
if(is_archive()) {
?>
<div id="bread-cat-list-archive">
<h2><?php echo $category->name; ?></h2>
@freezvd
freezvd / category_hierarchy.php
Created April 11, 2015 07:29
To achieve a pattern where Parent Category shows without count and their respective Child categories shown with count.
<?php
/*
This is what I wrote to achieve a pattern where Parent Category shows without count
and their respective Child categories shown with count. I am pretty sure that there is some neat
way to get this done, but I was not able to find that. Pls mention in comments if you knw any
other alternative approach.
Ex:
Parent
@freezvd
freezvd / related_posts_via_tags.php
Created April 11, 2015 07:29
Related posts with Fb Like and Tweet button.
@freezvd
freezvd / find_first_image_width.php
Created April 11, 2015 07:29
Scenario: You 'only' have 'url' of first image occurring in your 'the_content' and you want to find that image's width/height. Code goes in functions.php
<?php
/*
Here we will find out the WIDTH of 'first' image occuring in our 'the_content'
*/
/*
Step: 1
Using the famous 'catch_that_image' snippet, we will fetch the url of first image
occuring in the content and will pass the same url while calling a function to find
@freezvd
freezvd / 0_reuse_code.js
Last active August 29, 2015 14:18
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@freezvd
freezvd / functions.php
Last active August 29, 2015 14:18 — forked from srikat/functions.php
Add CCS id and class to....
//* Add a CSS ID to main element
add_filter( 'genesis_attr_content', 'custom_attributes_content' );
function custom_attributes_content( $attributes ) {
if ( is_home() || is_archive() ) {
$attributes['id'] = 'main-content-area';
}
return $attributes;
}
add_filter( 'wp_nav_menu_items', 'genesis_search_primary_nav_menu', 10, 2 );
/**
* @author Brad Dalton
* @example http://wpsites.net/web-design/add-search-form-to-any-genesis-nav-menu/
* @copyright 2014 WP Sites
*/
function genesis_search_primary_nav_menu( $menu, stdClass $args ){
if ( 'primary' != $args->theme_location )