Skip to content

Instantly share code, notes, and snippets.

@vadimsgr
vadimsgr / mywidget-basic.php
Created August 30, 2018 12:54 — forked from pommiegranit/mywidget-basic.php
Playing with WordPress widgets
<?php
/*
Plugin Name: My Widget
Plugin URI: http://mydomain.com
Description: My first widget
Author: Me
Version: 1.0
Author URI: http://mydomain.com
*/
@vadimsgr
vadimsgr / functions.php
Created January 9, 2018 14:21 — forked from corsonr/functions.php
Display WooCommerce product variations dropdown select on the shop page
<?php
// Display variations dropdowns on shop page for variable products
add_filter( 'woocommerce_loop_add_to_cart_link', 'woo_display_variation_dropdown_on_shop_page' );
function woo_display_variation_dropdown_on_shop_page() {
global $product;
if( $product->is_type( 'variable' )) {
@vadimsgr
vadimsgr / re-add-justify-text-button.php
Last active March 13, 2017 11:47
re-add justify text button to editor without plugin
/******************************************************
re-add justify text button to editor
******************************************************/
function readd_tiny_mce_button_justify( $buttons_array ){
if ( !in_array( 'alignjustify', $buttons_array ) ){
$rightButtonKey = array_search( 'alignright', $buttons_array );
$addKey = array( 'alignjustify' );
array_splice( $buttons_array, $rightButtonKey + 1, 0, $addKey );
}
add_action( 'pre_get_posts', 'change_posts_order_per_category' );
function change_posts_order_per_category( $query ) {
if ( ! is_admin() && $query->is_main_query() && $query->is_archive() && $query->get( 'cat' ) ) { // change 'cat' to your actual category slug
$query->set( 'order', 'ASC' );
}
}
@vadimsgr
vadimsgr / woocommerce_custom_tax.php
Created May 17, 2016 07:29
Create custom taxonomy for woocommerce
//************ Create custom taxonomy for woocommerce ************
function create_product_taxonomy() {
$labels = array(
'name' => _x( 'Product Categories', 'taxonomy general name' ),
'singular_name' => _x( 'Product Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Product Categories' ),
'all_items' => __( 'All Product Categories' ),
'parent_item' => __( 'Parent Product Category' ),
'parent_item_colon' => __( 'Parent Product Category:' ),
'edit_item' => __( 'Edit Product Category' ),
@vadimsgr
vadimsgr / wc-pagination-functions.php
Last active September 8, 2015 11:47 — forked from klihelp/wc-pagination-functions.php
WooCommerce shortcode pagination on pages
<?php
/**
* This code shows pagination for WooCommerce shortcodes when it's embeded on single pages.
* Include into functions.php.
*/
if ( ! is_admin() ) {
// ---------------------- FRONTPAGE -------------------
if ( defined('WC_VERSION') ) {