Skip to content

Instantly share code, notes, and snippets.

View vajrasar's full-sized avatar

Vajrasar Goswami vajrasar

View GitHub Profile
@vajrasar
vajrasar / save_post.php
Last active August 29, 2015 13:55
Not Working.
<?php
function vg_update_timestamp( $post_id ) {
$startdate = get_post_meta($post_id, 'cmb_from_textdate', true); //not unix timestamp
$enddate = get_post_meta($post_id, 'cmb_till_textdate', true); //not unix timestamp
$timestamp_start = strtotime( $startdate );
$timestamp_end = strtotime( $enddate );
@vajrasar
vajrasar / main_page.php
Created February 3, 2014 10:54
jQuery Masonry on a Custom Template.
<?php
/**
* The idea (advanced version) of using Masonry in WordPress was taken from Sridhar Katakam's blog post (Link Below).
* Here we are applying the idea in a different way. In this specific scene, we only need the Masonry goodness on Main Page.
* Link - http://sridharkatakam.com/using-masonry-genesis-pinterest-like-layout/
*
* NOTE: Here we did not use Masonry Brick for Image and CSS, as done in Sridhar's Tutorial. As, we already done some css
* work for .entry and gave it a fixed width; and images in this scene were not featured images or images directly fom post.
*
@vajrasar
vajrasar / prob.php
Last active August 29, 2015 13:56
Body Class is only applying on main-page.php and not on list-page.php
<?php
//* Add custom body class to the head
add_filter( 'body_class', 'sk_body_class' );
function sk_body_class( $classes ) {
if ( is_page_template( 'list-page.php' ) || is_page_template('main-page.php') || is_archive() )
$classes[] = 'masonry-page';
return $classes;
@vajrasar
vajrasar / category_hierarchy.php
Created March 7, 2014 12:19
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
<?php
/*
Template Name: Edit Listing
*/
add_filter('gform_field_value_post_title', 'vg_post_title');
add_filter('gform_field_value_post_content', 'vg_post_content');
add_filter('gform_field_value_post_add', 'vg_post_add');
add_filter('gform_field_value_post_mobile', 'vg_post_mobile');
@vajrasar
vajrasar / custom-accordion-cats.php
Last active August 29, 2015 13:59
It's a mix of jQuery Accordion plus Categories from WordPress (both tweaked to suit need). The inspiration of this comes from - http://www.truelocal.com.au/business-type
<?php
/**
The inspiration of this comes from - http://www.truelocal.com.au/business-type
Visit the link to see what we are aiming at.
It's a mix of jQuery Accordion plus Categories from WordPress (both tweaked to suit need).
The 'jquery-ui.css' mentioned below can be taken from jQuery's site.
@vajrasar
vajrasar / child_cat.php
Created May 9, 2014 11:20
To get child categories of parent in single post.
<?php
$category = get_the_category();
$category = get_category ($category[0]->cat_ID);
if ($category->cat_ID) {
if(!$category->category_parent) // if category has NO parent
$children = wp_list_categories("orderby=id&depth=0&hide_empty=0&title_li=&child_of=".$category->cat_ID."&echo=0");
@vajrasar
vajrasar / child_cat_archives.php
Last active August 29, 2015 14:01
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>
@vajrasar
vajrasar / custom_navigation.php
Last active August 29, 2015 14:06
Add custom Navigation Menu Location in Genesis.
<?php
/*
Part One: Registering the custom Menu
*/
add_action( 'init', 'register_my_menu' );
function register_my_menu() {
register_nav_menu( 'cpt-menu', __( 'CPT Menu' ) );
@vajrasar
vajrasar / functions.php
Created September 6, 2014 07:58
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