Skip to content

Instantly share code, notes, and snippets.

View sanjayatony's full-sized avatar
🏠
Working from home

Tony Sanjaya sanjayatony

🏠
Working from home
View GitHub Profile
@sanjayatony
sanjayatony / index.php
Last active August 29, 2015 14:02
Get post by ID
<?php echo apply_filters('the_content', get_post(21)->post_content);?>
@sanjayatony
sanjayatony / function.php
Last active August 29, 2015 14:04
change order woocommerce tabs
<?php
add_filter( 'woocommerce_product_tabs', 'woo_reorder_tabs', 98 );
function woo_reorder_tabs( $tabs ) {
$tabs['reviews']['priority'] = 5; // Reviews first
$tabs['description']['priority'] = 10; // Description second
$tabs['additional_information']['priority'] = 15; // Additional information third
return $tabs;
}
?>
@sanjayatony
sanjayatony / blog.php
Last active August 29, 2015 14:04
wordpress is_blog
<?php
function is_blog () {
global $post;
$posttype = get_post_type($post );
return ( ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag())) && ( $posttype == 'post') ) ? true : false ;
}
?>
//cara penggunaan
<?php if (is_blog()) { echo 'you are on blog page'; } ?>
@sanjayatony
sanjayatony / 0_reuse_code.js
Last active August 29, 2015 14:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@sanjayatony
sanjayatony / function.php
Last active August 29, 2015 14:08
Change currency symbol woocommerce
<?php
add_filter('woocommerce_currency_symbol', 'change_existing_currency_symbol', 10, 2);
function change_existing_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'SGD': $currency_symbol = '<span class="cur-sym">SGD</span>'; break;
}
return $currency_symbol;
}
?>
@sanjayatony
sanjayatony / style.css
Created November 2, 2014 14:45
css for webkit only
@media screen and (-webkit-min-device-pixel-ratio:0) {
/* CSS Statements that only apply on webkit-based browsers (Chrome, Safari, etc.) */
body { background:#ccc; }
}
@sanjayatony
sanjayatony / uri.php
Last active August 29, 2015 14:15
get uri segments
<?php
///How to get the second segment in URL without slashes?
//For example I have a URL`s like this http://foobar/first/second.
$_SERVER['REQUEST_URI_PATH'] = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$segments = explode('/', $_SERVER['REQUEST_URI_PATH']);
echo $segments[1];
?>
@sanjayatony
sanjayatony / files_permission
Last active August 29, 2015 14:28
File permission for wordpress
sudo find . -type f -exec chmod 664 {} +
sudo find . -type d -exec chmod 775 {} +
sudo chmod 660 wp-config.php
@sanjayatony
sanjayatony / loop.php
Last active November 3, 2020 12:29
loop custom post type
<?php
$args = array(
'post_type' => 'post',
'posts_per_page' => 4,
'paged' => $paged
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();?>
<h2><a href="<?php the_permalink();?>"><?php the_title();?></a></h2>
<span class="date"><?php the_date();?></span>
@sanjayatony
sanjayatony / plugin.php
Last active July 4, 2016 06:06
add reading time in twitter card, so it will show up when unfurl
<?php
/*
Plugin Name: Reading Time
Plugin URI: http://wordpress.org/extend/plugins/estimated-post-reading-time/
Description: Calculates an average required time to complete reading a post.
Version: 1.4
Author: Konstantinos Kouratoras
Author URI: http://www.kouratoras.gr
Author Email: [email protected]