Skip to content

Instantly share code, notes, and snippets.

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

Trang Sĩ Hưng trangsihung

🏠
Working from home
View GitHub Profile
@trangsihung
trangsihung / _blank.js
Created March 2, 2020 01:16 — forked from CrocoDillon/_blank.js
Automatically open external links in new tab or window.
// vanilla JavaScript
var links = document.links;
for (var i = 0, linksLength = links.length; i < linksLength; i++) {
if (links[i].hostname != window.location.hostname) {
links[i].target = '_blank';
}
}
// or in jQuery
@trangsihung
trangsihung / gist:8a9b7efea7226879393adbcbb431dc5f
Created August 23, 2016 02:29 — forked from mikejolley/gist:2176823
WooCommerce - Show products from current product category (when viewing a single product)
<?php
if ( is_singular('product') ) {
global $post;
// get categories
$terms = wp_get_post_terms( $post->ID, 'product_cat' );
foreach ( $terms as $term ) $cats_array[] = $term->term_id;
@trangsihung
trangsihung / wp_update_term.php
Created December 29, 2015 03:11 — forked from hinnerk-a/wp_update_term.php
Using wp_update_term properly for setting parent terms in hierarchical taxonomies
<?php
// set terms
wp_set_object_terms( $post_id, $object_types, 'immomakler_object_type', true );
// make terms hierarchial by objektart
$term_parent = get_term_by( 'slug', $openimmo_data['objektart'], 'immomakler_object_type' );
$term_child = get_term_by( 'slug', $openimmo_data['objektart_detail'], 'immomakler_object_type' );
delete_option( 'immomakler_object_type_children' ); // workaround for WordPress not updating this option properly
<!DOCTYPE html>
<html>
<head>
<title>Box Shadow</title>
<style>
.box {
height: 150px;
width: 300px;
margin: 20px;
@trangsihung
trangsihung / gist:8054574
Created December 20, 2013 13:11 — forked from Dimox/dimox_breadcrumbs.php
dimox breadcrumbs
<?php
function dimox_breadcrumbs() {
/* === OPTIONS === */
$text['home'] = 'Home'; // text for the 'Home' link
$text['category'] = 'Archive by Category "%s"'; // text for a category page
$text['search'] = 'Search Results for "%s" Query'; // text for a search results page
$text['tag'] = 'Posts Tagged "%s"'; // text for a tag page
$text['author'] = 'Articles Posted by %s'; // text for an author page