Skip to content

Instantly share code, notes, and snippets.

View alispx's full-sized avatar

ALI MAHFUD alispx

View GitHub Profile
<?php $args = array(
'post_type' => 'post_type',
'showposts' => 200,
'orderby' => 'menu_order',
'order' => 'ASC'
);
$customquery = new WP_Query( $args ); ?>
<?php
<?php
$args = array(
'post_type' => 'post_type',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'posts_per_page' => 24,
'orderby' => 'date',
'order' => 'desc',
);
<?php
$thumbnail_id = get_post_thumbnail_id( get_the_ID() );
$img_url = wp_get_attachment_url( $thumbnail_id );
if ( ! empty( $thumbnail_id ) ) {
echo wp_get_attachment_image( $thumbnail_id, 'thumbnail' );
} else {
echo '<img src="http://placehold.it/300x300" />';
}
?>
/**
* Change your product per page
* @author alispx
*/
add_filter( 'loop_shop_per_page', 'woo_shop_per_page' );
function woo_shop_per_page() {
return 12;
}
@alispx
alispx / 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
<link rel='stylesheet' id='style' href='http://local.wordpress.dev/alispx/wp-content/themes/highwind/style.css?ver=1.0' type='text/css' media='all' />
<script type='text/javascript' src='http://local.wordpress.dev/alispx/wp-includes/js/jquery/jquery.js?ver=1.11.1'></script>
function _remove_script_version( $src ){
$parts = explode( '?', $src );
return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );
<?php
/*
Template Name: Update Network
*/
get_header();
if ( is_user_logged_in() ) {
<?
/**
* Repeatable Custom Fields in a Metabox
* Author: Helen Hou-Sandi
*
* From a bespoke system, so currently not modular - will fix soon
* Note that this particular metadata is saved as one multidimensional array (serialized)
*/
function hhs_get_sample_options() {
@alispx
alispx / Kamus-layers.php
Created May 26, 2015 21:55
Kamus Layers Widget
// Design Bar
$this->design_bar(
'side', // CSS Class Name
array(
'name' => $this->get_field_name( 'design' ),
'id' => $this->get_field_id( 'design' ),
), // Widget Object
$instance, // Widget Values
array(
'layout',