Skip to content

Instantly share code, notes, and snippets.

View aprakasa's full-sized avatar
🎯
Focusing

Arya Prakasa aprakasa

🎯
Focusing
View GitHub Profile
@aprakasa
aprakasa / WooCommerce - Display Category Image
Created December 2, 2012 09:10
WooCommerce - Display Category Image
// verify that this is a product category page
if (is_product_category()){
global $wp_query;
// get the query object
$cat = $wp_query->get_queried_object();
// get the thumbnail id user the term_id
$thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );
// get the image URL
$image = wp_get_attachment_url( $thumbnail_id );
// print the IMG HTML
@aprakasa
aprakasa / gist:3935970
Created October 23, 2012 00:50
get attachment ID based on src
/**
* This is helper function will get attachment ID based on src
*
* @see http://wordpress.org/support/topic/need-to-get-attachment-id-by-image-url
*/
function get_attachment_id_from_src( $url ) {
global $wpdb;
$id = url_to_postid( $url );
if( $id == 0 ) {
@aprakasa
aprakasa / gist:3780367
Created September 25, 2012 06:58
wp_editor() and Genesis Admin Page
<?php
class Test_Setting_Admin extends Genesis_Admin_Boxes {
/**
* Create an admin menu item and settings page.
*
* @since 1.0
*/
function __construct() {
@aprakasa
aprakasa / gist:3774281
Created September 24, 2012 05:11
Simple social share
<!-- Twitter share -->
<a href="http://twitter.com/?status=<?php the_title(); ?>%20<?php echo wp_get_shortlink(get_the_ID()); ?>" onclick="window.open(this.href); return false;">TWITTER</a>
<!-- Facebook -->
<a href="http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&amp;t=<?php the_title(); ?>" onclick="window.open(this.href); return false;">FACEBOOK</a>
<!-- Google plus -->
<a href="https://plus.google.com/share?url=<?php the_permalink();?>" onclick="javascript:window.open(this.href,'', 'menubar=no, toolbar=no, resizable=yes, scrollbars=yes,height=600,width=600');return false;">Google plus</a>
<!-- Pinterest -->
@aprakasa
aprakasa / gist:3729495
Created September 15, 2012 19:56
Exclude category from feed
/** Exclude category from feed */
function excludecatfeed($query) {
if(is_feed()) {
$query->set('category__not_in','-1');
return $query;
}
}
add_filter('pre_get_posts', 'excludecatfeed');