Skip to content

Instantly share code, notes, and snippets.

View anandkumar's full-sized avatar

Anand Kumar anandkumar

View GitHub Profile
@anandkumar
anandkumar / functions.php
Last active January 14, 2020 21:11
bbPress: Reverse forum replies order from newer to older
// Reverse forum replies order from newer to older
function custom_bbp_has_replies() {
$args['order'] = 'DESC'; // ‘ASC’ (Ascending, Default), 'DESC' (Descending)
return $args;
}
add_filter('bbp_before_has_replies_parse_args', 'custom_bbp_has_replies' );
@anandkumar
anandkumar / functions.php
Created August 21, 2013 12:30
Force full width layout on bbPress forums
/** Force full width layout on bbPress forums */
add_filter( 'genesis_pre_get_option_site_layout', 'child_do_layout' );
function child_do_layout( $opt ) {
if ( is_bbpress() ) {
$opt = 'full-width-content'; // Change this to any Genesis layout
return $opt;
}
}
@anandkumar
anandkumar / header.js
Created August 14, 2013 11:55
Color table using javascript.
<script type="text/javascript">jQuery(document).ready(function ($) {
$('table').css({
'border-collapse':'collapse'
});
$('tr th').css({'background':'#666666', 'color':'#ffffff', 'font-family':'verdana', 'font-weight':'normal'});
// Here using jquery selectors
$('tr:even').css({'background':'#f5f5f5'});
<html>
<head>
....
YOUR ADSENSE CSS CODE HERE
</head>
<body>
<script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
....
<!-- Adsense Ad Unit 1 -->
@anandkumar
anandkumar / adsense.html
Last active December 20, 2015 18:18
official responsive Adsense ad unit format - Async
<style>
.adsense-ad-unit-1 { width: 320px; height: 50px; }
@media(min-width: 500px) { .adsense-ad-unit-1 { width: 468px; height: 60px; } }
@media(min-width: 800px) { .adsense-ad-unit-1 { width: 728px; height: 90px; } }
</style>
<script async src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Adsense Ad Unit 1 -->
<ins class="adsense-ad-unit-1"
@anandkumar
anandkumar / gist:6097680
Created July 28, 2013 06:40
.htaccess domain change
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^old-domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.old-domain.com$
RewriteRule (.*)$ http://www.new-domain.com/$1 [R=301,L]
</IfModule>
<script type="text/javascript">
jQuery(document).ready(function($) {
// Share bar
if ($('body').hasClass('single')) {
var timeout = null; var entryShare = $('#social-widgets').first(); var entryContent =$('.entry-content').first();
$(window).scroll(function () {
var scrollTop = $(this).scrollTop();
if(!timeout) {
timeout = setTimeout(function() { timeout = null;
if (entryShare.css('position') !== 'fixed' && entryShare.offset().top < $(document).scrollTop()) {
@anandkumar
anandkumar / responsive-adsense.html
Created June 18, 2013 15:31
responsive adsense
<!-- You can add multiple Adsense Ad units -->
<!-- Replace ca-pub-1234567890 and ad-slots AAA, BBB, CCC, DDD, EEE, FFF -->
<div id="google-ads-1">
<script type="text/javascript">
adUnit = document.getElementById("google-ads-1");
adWidth = adUnit.offsetWidth;
/* Replace this with your AdSense Publisher ID */
@anandkumar
anandkumar / button-script.htm
Last active December 18, 2015 15:29
Genesis Sticky Social Sharebar (v2.0) (includes tweet, fb like, G+ and buffer buttons. Tutorial link: http://www.blogsynthesis.com/?p=1090) I have just updated the code for the old tutorial. Now it supports Genesis 2.0 and Responsive design. Follow the tutorial for easy installation to your Genesis based Wordpress sites.
<!-- Place these tags at wp_footer() from Genesis Dashboard. -->
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'http://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
/** Add rel="next" and rel="prev" to Genesis Framework **/
function custom_post_navigation()
{
?>
<div class="prev-next">
<div class="nav-prev">
<?php previous_post_link('%link', '%title'); ?>
</div>
<div class="nav-next">
<?php next_post_link('%link', '%title'); ?>