Skip to content

Instantly share code, notes, and snippets.

View INDIAN2020's full-sized avatar

Gogula Sivannarayana INDIAN2020

View GitHub Profile
@INDIAN2020
INDIAN2020 / gist:4494641
Created January 9, 2013 16:41
HTML: basic template
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<!--<meta http-equiv="refresh" content="2">-->
<title>refresh</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
@INDIAN2020
INDIAN2020 / box.css
Created February 6, 2013 12:21
box
.box{
width: 728px;
height: 90px;
padding: 5px;
display: inline-block;
-moz-box-shadow: 0 0 8px #8b3d92;
-webkit-box-shadow: 0 0 8px #8b3d92;
box-shadow: 0 0 8px #8b3d92;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
@INDIAN2020
INDIAN2020 / getid
Created February 7, 2013 09:08
getid
global $wpdb;
$post_name = get_query_var('name');
$post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = $post_name");
@INDIAN2020
INDIAN2020 / wp-cloud
Created February 7, 2013 16:09
remove title from tagcloud
/*
Remove title attribute from wp_tag_cloud
Adding this snippet to the functions.php of your wordpress theme will remove the title=”” attribute from the anchor tags when using wp_tag_cloud.
*/
function replace_wps_title_att($output) {
$output = preg_replace('` title="(.+)"`', '', $output);
return $output;
}
@INDIAN2020
INDIAN2020 / wp-userrolechange
Created February 7, 2013 16:10
user role change email
/*
Send email notification when user role changes
Adding this snippet to the functions.php of your wordpress theme will send the member an email notification when the user’s role has changed.
*/
function user_role_update( $user_id, $new_role ) {
$site_url = get_bloginfo('wpurl');
$user_info = get_userdata( $user_id );
$to = $user_info->user_email;
$subject = "Role changed: ".$site_url."";
@INDIAN2020
INDIAN2020 / wp-postdivider
Created February 7, 2013 16:11
post divider
/*
Add post divider in between two posts or more
Add this snippet right before the closing of the loop to auto insert a post divider “div” that you can style using the “post-item-divider” class.
*/
<?php
if (($wp_query->current_post + 1) < ($wp_query->post_count)) {
echo '<div class="post-item-divider">Post Divider</div>';
}
?>
@INDIAN2020
INDIAN2020 / wp-adjestthemesetting
Created February 7, 2013 16:13
Adjust settings on theme activation
/*
Adjust settings on theme activation
Place this in your functions.php to adjust your default WordPress settings when activating your theme for the first time. This function also deletes the default post, page and comment that are created when you install WordPress.
*/
add_action( 'after_setup_theme', 'the_theme_setup' );
function the_theme_setup()
{
// First we check to see if our default theme settings have been applied.
$the_theme_status = get_option( 'theme_setup_status' );
@INDIAN2020
INDIAN2020 / wp-nfm
Created February 8, 2013 01:09
number of file in media
/*
Count total number of jpg, gif, png images in media library
Adding the first snippet to the functions.php of your wordpress theme will display a count of all images within the media library. Add the second snippet in the location you wish to display the count total.
use this : <?php img_count(); ?>
*/
function img_count(){
$query_img_args = array(
'post_type' => 'attachment',
'post_mime_type' =>array(
@INDIAN2020
INDIAN2020 / wp-countshow
Created February 8, 2013 01:10
display content after specified date
/*
Countdown timer shortcode, display content after specified date
use this : [cdt month="10" day="17" year="2011"]
This is content that will only be shown after a set number of days.
*/
function content_countdown($atts, $content = null){
extract(shortcode_atts(array(
'month' => '',
'day' => '',
@INDIAN2020
INDIAN2020 / gist:5495487
Created May 1, 2013 14:15
wordpress: image shortcode
/* [image src="" width="" height="" align=""][/image] */
add_shortcode("image","gsn_image");
function gsn_image($atts, $content=''){
extract( shortcode_atts( array(
'src' => 'none',
'content'=> $content,
'width' => '',
'height' => '',
'align' => 'center'
), $atts ) );