Skip to content

Instantly share code, notes, and snippets.

View alispx's full-sized avatar

ALI MAHFUD alispx

View GitHub Profile
@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
/**
* Change your product per page
* @author alispx
*/
add_filter( 'loop_shop_per_page', 'woo_shop_per_page' );
function woo_shop_per_page() {
return 12;
}
<?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" />';
}
?>
<?php
$args = array(
'post_type' => 'post_type',
'post_status' => 'publish',
'ignore_sticky_posts' => 1,
'posts_per_page' => 24,
'orderby' => 'date',
'order' => 'desc',
);
<?php $args = array(
'post_type' => 'post_type',
'showposts' => 200,
'orderby' => 'menu_order',
'order' => 'ASC'
);
$customquery = new WP_Query( $args ); ?>
<?php