Skip to content

Instantly share code, notes, and snippets.

View vajrasar's full-sized avatar

Vajrasar Goswami vajrasar

View GitHub Profile
@vajrasar
vajrasar / loop.php
Created August 1, 2015 15:48
Jetpack Issue
<div class="row">
<?php
$prod_arch_args = array(
'post_type' => 'products',
'posts_per_page' => '12',
'paged' => get_query_var( 'paged' ),
);
$prod_arch_query = new WP_Query( $prod_arch_args );
if( $prod_arch_query->have_posts() ) {
@vajrasar
vajrasar / acf_term_list.php
Created July 2, 2015 10:20
Using ACF for taxonomy images.
<?php
$prod_cats = get_terms( 'product_cat', 'hide_empty=0' );
?>
<ul class="gk-special-menu">
<?php
foreach( $prod_cats as $cat ){
$name = $cat->name;
$prod_term_link = get_term_link( $cat );
@vajrasar
vajrasar / youtube.html
Created June 30, 2015 07:22
Using Youtube iFrame for videos
<!-- topplayer is the div id we'll be referencing in JS to make an iframe here -->
<div id="topplayer"></div>
<script>
jQuery( document ).ready(function( $ ) {
var tag = document.createElement( 'script' );
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName( 'script' )[0];
firstScriptTag.parentNode.insertBefore( tag, firstScriptTag );
});
@vajrasar
vajrasar / youtube.html
Created June 30, 2015 07:14
Using Youtube iFrame API for playlist
<!-- topplayer is the div id we'll be referencing in JS to make an iframe here -->
<div id="topplayer"></div>
<script>
jQuery( document ).ready(function( $ ) {
var tag = document.createElement( 'script' );
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName( 'script' )[0];
firstScriptTag.parentNode.insertBefore( tag, firstScriptTag );
});
@vajrasar
vajrasar / functions.php
Created June 27, 2015 10:37
Working php session logic (changes made in functions.php file)
function vg_show_post_id() {
$p_id = $_REQUEST['post_id'];
$title = get_the_title( $p_id );
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
if (!empty($_SESSION['cart']) && array_key_exists( $p_id, $_SESSION['cart'] ) ) {
$cnt = $_SESSION['cart'][$p_id];
$cnt++;
$_SESSION['cart'][$p_id] = $cnt;
@vajrasar
vajrasar / Details.html
Last active August 29, 2015 14:23
AJAX with WP_Session [Read Details.html here for details]
The concept is to put a Button in Post Content which the user will click.
Two things - The ID of the post and Number of times the user clicks the Button should be displayed.
Underlaying Reason - With this we are presenting Posts as Products and with that button user can add products,
and number of clicks on the button will signify the quantity that he wants.
The logic is working well with the normal php session, but not working with WP_Session.
Working php session - https://gist.github.com/vajrasar/8a8aa97de1b39f18ef29
@vajrasar
vajrasar / comment_form.php
Last active August 29, 2015 14:23
Modifying Comment Form & Comment List along with its Markup
<?php
//Disabling URL field
function vg_disable_comment_url( $fields ) {
unset( $fields['url'] );
return $fields;
}
add_filter('comment_form_default_fields','vg_disable_comment_url');
//To edit defaults in comment field
@vajrasar
vajrasar / tooltip_css.css
Last active August 29, 2015 14:20
To show excerpt in tooltip while user hovers on title
.hide-excerpt {
display: none;
}
#powerTip {
max-width: 300px;
white-space: normal !important;
}
@vajrasar
vajrasar / func.php
Last active August 29, 2015 14:20
For Tut: Adding Inline logo via Theme Options in Genesis
<?php
//* Add the theme-opt.php file
require_once('theme-opt.php');
/**********************************
*
* Replace Header Site Title with Inline Logo
*
* Fixes Genesis bug - when using static front page and blog page (admin reading settings) Home page is <p> tag and Blog page is <h1> tag
@vajrasar
vajrasar / enviratitle.php
Last active August 29, 2015 14:17
[Envira Gallery] Title with Link to Image (LightBox) - Problem
<?php
/*
This was working fine, I was able to show Title of image with a hyperlink to image lightbox.
But suddenly from past a week site was down, when I checked error logs it stated
that the code (which was in my functions.php) is throwing error - PHP Parse error: syntax error, unexpected '['
That error was in Line 24 of this code.
*/