Skip to content

Instantly share code, notes, and snippets.

View Aziz-Rahman's full-sized avatar

Aziz Rahman Aji Aziz-Rahman

View GitHub Profile
@Aziz-Rahman
Aziz-Rahman / Custom_Post_Type.php
Last active October 4, 2017 03:08
Custom Post Type & Custom Taxonomy
<?php
/**
* Custom Post Type Pegawai
*
* @package WordPress
* @subpackage Latihan
* @since Latihan 1.0
*/
?>
<?php
@Aziz-Rahman
Aziz-Rahman / datediff.php
Last active August 29, 2015 14:14
Menghitung selisih usia dengan php pd wordpress custom field tanggal lahir
<?php
if ( ! function_exists( 'datediff' ) ) {
function datediff($tgl1, $tgl2){
$tgl1 = strtotime($tgl1);
$tgl2 = strtotime($tgl2);
$diff_secs = abs($tgl1 - $tgl2);
$base_year = min(date("Y", $tgl1), date("Y", $tgl2));
$diff = mktime(0, 0, $diff_secs, 1, 1, $base_year);
return array(
"years" => date("Y", $diff) - $base_year,
@Aziz-Rahman
Aziz-Rahman / Sortcodes_link.php
Last active August 29, 2015 14:14
Sortcodes in Wordpress
@Aziz-Rahman
Aziz-Rahman / Wp_Query.php
Last active August 29, 2015 14:14
Simple Wp_Query Wordpress
<?php
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'meta_key' => 'tanggal_lahir', //id
'orderby' => 'meta_value',
'order' => 'DESC',
);
$wp_query = new WP_Query();
$wp_query->query( $args );
@Aziz-Rahman
Aziz-Rahman / get_terms.php
Created February 2, 2015 04:52
Get Terms Taxonomy in Wordpress
<?php
// Select taxonmony
$taxonomies = array(
'kb_category',
);
// Filter taxonomy
$args = array(
'hide_empty' => false,
);
@Aziz-Rahman
Aziz-Rahman / even_odd.php
Last active August 29, 2015 14:15
Ganjil genap post wp
<?php while( $wp_query->have_posts() ): $wp_query->the_post();
if ($wp_query->current_post % 2 == 0):
//odd
else:
//even
endif
endwhile
?>
@Aziz-Rahman
Aziz-Rahman / fungsi_breadcrumb.php
Created February 16, 2015 02:22
Breadcrumb pada wordpress (Tanpa Plugin)
<?php
/**
* Function to display breadcrumb
*
* @package WordPress
* @subpackage My Theme
* @since My Theme 1.0.0
*/
function the_breadcrumb() {
if (!is_home()) {
@Aziz-Rahman
Aziz-Rahman / meta.php
Created February 16, 2015 02:39
To Display meta
<?php
/**
* Function to display post meta
*
* @package WordPress
* @subpackage My Theme
* @since My Theme 1.0.0
*/
if ( ! function_exists( 'my_post_meta' ) ) {
function my_post_meta() {
@Aziz-Rahman
Aziz-Rahman / form1.html
Created February 16, 2015 04:24
HTML5 form
<!DOCTYPE html>
<html>
<body>
<!-- Example -->
<form action="">
<input type="number" name="quantity" min="1" max="5">
<input type="date" />
<input type="time" />
<input type="month" />
@Aziz-Rahman
Aziz-Rahman / shortcodes-article-category.php
Created February 17, 2015 02:25
Shortcodes untuk menampilkan CATEGORY ARTICLE dengan CATEGORY-nya masing2
<?php
/**
* Shortcodes Article Category
* Untuk menampilkan semua category article dengan categorynya masing2 (di dlm tiap2 category article ada categorynya masing2)
* @package WordPress
* @subpackage Lat
* @since Lat 1.0.0
*/
//shortcodes Category