Skip to content

Instantly share code, notes, and snippets.

View rabbitinblack's full-sized avatar

Sittipong Wiboonsirichai rabbitinblack

View GitHub Profile
@rabbitinblack
rabbitinblack / Wordpress : Head
Created August 6, 2013 03:30
Wordpress : Head for header.php
<!DOCTYPE html>
<!--[if IE 7]>
<html class="ie ie7" <?php language_attributes(); ?>>
<![endif]-->
<!--[if IE 8]>
<html class="ie ie8" <?php language_attributes(); ?>>
<![endif]-->
<!--[if !(IE 7) | !(IE 8) ]><!-->
<html <?php language_attributes(); ?>>
<!--<![endif]-->
@rabbitinblack
rabbitinblack / WordPress : Custom Page Template
Created September 20, 2013 03:53
WordPress : Custom Page Template
<?php
/*
Template Name: Snarfer
*/
?>
@rabbitinblack
rabbitinblack / WordPress : WP_Query
Created September 20, 2013 05:48
WordPress : WP_Query
<?php
$args = array(
'cat' => 1,
'posts_per_page' => 4
);
$custom_query = new WP_Query($args);
while($custom_query->have_posts()) : $custom_query->the_post(); ?>
<?php endwhile; ?>
<?php wp_reset_postdata(); // reset the query ?>
@rabbitinblack
rabbitinblack / WordPress : Excerpt Has Tag
Last active December 24, 2015 22:09
WordPress : Excerpt Has Tag
function custom_wp_trim_excerpt($text) {
$raw_excerpt = $text;
if ( '' == $text ) {
$text = get_the_content('');
$text = strip_shortcodes( $text );
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]&gt;', $text);
@rabbitinblack
rabbitinblack / remove_image_size.php
Last active August 29, 2015 14:03
Function Reference/remove image size
<?php remove_image_size($name); ?>
<?php
add_action('after_setup_theme', 'change_plugin_image_size');
function change_plugin_image_size() {
remove_image_size('plugin-image');
add_image_size('plugin-image', 300, 150, true);
}
?>
@rabbitinblack
rabbitinblack / WordPress:PluginHeader
Created July 8, 2014 02:12
Wordpress : Plugin Header Comment
<?php
/**
* Plugin Name:
* Plugin URI:
* Description:
* Version: 1.0
* Author: Rabbitinblack
* Author URI: http://www.rabbitinblack.com
* License: GPL2
*/
@rabbitinblack
rabbitinblack / add-to-cart.php
Last active August 29, 2015 14:06
WooCommerce Default Add to cart File
<?php
/**
* Loop Add to Cart
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.1.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@rabbitinblack
rabbitinblack / mo-add-to-cart.php
Last active August 29, 2015 14:06
Modified WooCommerce Add to cart Button Auto add product to cart
<?php
/**
* Loop Add to Cart
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.1.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Retrieve path of singular template in current or parent template.
*
* The template path is filterable via the 'singular_template' hook.
*
* @since 4.3.0
*
* @see get_query_template()
*
* @return string Full path to singular template file