Skip to content

Instantly share code, notes, and snippets.

View hemusyl's full-sized avatar

Humayun Kabir hemusyl

View GitHub Profile
@hemusyl
hemusyl / single-page-walker.php
Created May 15, 2017 03:23 — forked from ninnypants/single-page-walker.php
Nav walker for single page WordPress sites
<?php
class Single_Page_Walker extends Walker_Nav_Menu{
function start_el(&$output, $item, $depth, $args) {
global $wp_query;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$classes[] = 'menu-item-' . $item->ID;
@hemusyl
hemusyl / Wordpress featured images expanded
Created April 13, 2017 16:03 — forked from austinginder/Wordpress featured images expanded
Wordpress adding multiple featured images per post
@hemusyl
hemusyl / index.php
Created March 12, 2017 06:30 — forked from jameskoster/index.php
WooCommerce - Sample products loop
<ul class="products">
<?php
$args = array(
'post_type' => 'product',
'posts_per_page' => 12
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
while ( $loop->have_posts() ) : $loop->the_post();
wc_get_template_part( 'content', 'product' );
@hemusyl
hemusyl / method-overlap.php
Created January 25, 2017 21:20 — forked from nahid/method-overlap.php
This gist is for PHP traits Example
<?php
trait Greetings
{
public function sayHello()
{
return 'Hello Bro';
}
public function goodBye()
@hemusyl
hemusyl / tabbed_taxonomy.php
Last active May 9, 2016 18:05 — forked from FernE97/tabbed_taxonomy.php
PHP: WordPress custom taxonomy/post query
<?php
$args = array(
'orderby' => 'ID'
);
$terms = get_terms( 'testimonial_category', $args );
?>
<!-- bootstrap tabs -->
<ul class="nav-tabs">
<?php
<?php
global $paged;
$posts_per_page = 9;
$settings = array(
'showposts' => $posts_per_page,
'post_type' => 'portfolio',
'orderby' => 'menu_order',
'order' => 'ASC',
'paged' => $paged)
);
@hemusyl
hemusyl / add-to-cart.php
Created January 30, 2016 05:38 — forked from claudiosanches/add-to-cart.php
WooCommerce - Template add-to-cart.php with quantity and Ajax!
<?php
/**
* Custom Loop Add to Cart.
*
* Template with quantity and ajax.
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
global $product;
@hemusyl
hemusyl / functions.php
Created January 30, 2016 05:29 — forked from woogist/functions.php
Set a custom add to cart URL to redirect to
/**
* Set a custom add to cart URL to redirect to
* @return string
*/
function custom_add_to_cart_redirect() {
return 'http://www.yourdomain.com/your-page/';
}
add_filter( 'woocommerce_add_to_cart_redirect', 'custom_add_to_cart_redirect' );
@hemusyl
hemusyl / gist:cce281d03c2d2d808bb0
Created January 27, 2016 08:16 — forked from webaware/gist:6260468
WooCommerce purchase page add-to-cart with quantity and AJAX, without customising any templates. See blog post for details: http://snippets.webaware.com.au/snippets/woocommerce-add-to-cart-with-quantity-and-ajax/
<?php
/**
* start the customisation
*/
function custom_woo_before_shop_link() {
add_filter('woocommerce_loop_add_to_cart_link', 'custom_woo_loop_add_to_cart_link', 10, 2);
add_action('woocommerce_after_shop_loop', 'custom_woo_after_shop_loop');
}
add_action('woocommerce_before_shop_loop', 'custom_woo_before_shop_link');
@hemusyl
hemusyl / wc-add-images-order-email-table.php
Last active January 22, 2016 15:01 — forked from bekarice/wc-add-images-order-email-table.php
Add images to WooCommerce emails
// Edit order items table template defaults
// https://www.sellwithwp.com/how-to-add-information-to-woocommerce-emails/
function sww_add_wc_order_email_images( $table, $order ) {
ob_start();
$template = $plain_text ? 'emails/plain/email-order-items.php' : 'emails/email-order-items.php';
wc_get_template( $template, array(
'order' => $order,
'items' => $order->get_items(),