Skip to content

Instantly share code, notes, and snippets.

View akshuvo's full-sized avatar

Akhtarujjaman Shuvo akshuvo

View GitHub Profile
@akshuvo
akshuvo / custom-post-taxonomy-permalinks.php
Created May 8, 2018 07:30 — forked from kasparsd/custom-post-taxonomy-permalinks.php
Create permalink structure URLs for custom post types that include all parent terms from a custom taxonomy
<?php
/*
Term Archive Pages:
- http://example.com/recipes/dinner/
- http://example.com/recipes/breakfast,brunch/
Single Recipe Pages:
- http://example.com/recipes/dinner/soup-title/
@akshuvo
akshuvo / readme.md
Created June 2, 2018 06:09 — forked from hitautodestruct/readme.md
Generate a custom structure for Wordpress menus.

This gist is for showing an example of a custom wordpress menu.

If you want to get more from the menu item simply have a look at the $item object. i.e:

// Will return a large object with lots of props like title, url, description, id etc.
var_dump( $item );

This code works on Wordpress 4.1.1 as of 31st of March 2015

<?php
// Visual composer get terms on dropdown params
if( !function_exists('vcdd_get_terms') ){
function vcdd_get_terms( $taxonomy = 'category' ){
$get_categories = get_categories( array(
'taxonomy' => $taxonomy,
) );
foreach ( $get_categories as $category ) {
$categories[] = [ $category->term_id => $category->name ];
}
@akshuvo
akshuvo / woocommerce_update_shipping_costs.php
Created October 15, 2018 08:35 — forked from neamtua/woocommerce_update_shipping_costs.php
WooCommerce: Update shipping costs on checkout using ajax
<script type="text/javascript">
/* in order to update info on your checkout page you need to trigger update_checkout function
so add this in your javascript file for your theme or plugin
*/
jQuery('body').trigger('update_checkout');
/* what this does is update the order review table but what it doesn't do is update shipping costs;
the calculate_shipping function of your shipping class will not be called again;
so if you were like me and you made a shipping method plugin and you had to change costs based on payment method then
add_shortcode( 'global_recent_posts', 'global_recent_posts_sc' );
function global_recent_posts_sc( $atts ) {
$atts = wp_parse_args( $atts, array(
'order' => 'ASC',
'orderby' => 'post_title',
'is_meta' => 0,
'post_type' => 'post',
'post_status' => 'publish',
'recentglobalpostsdisplay' => 'title_content',
'recentglobalpostsnumber' => '5',
function bd_woocommerce_quantity_input_args( $args, $product ) {
$args['input_value'] = 1; // Starting value
$args['max_value'] = 800; // Maximum value
$args['min_value'] = 1; // Minimum value
$args['step'] = 1; // Quantity steps
return $args;
}
add_filter( 'woocommerce_quantity_input_args', 'bd_woocommerce_quantity_input_args', 10, 2 );
@akshuvo
akshuvo / woorommerce-customfield-and-email.php
Created January 28, 2019 07:44
Add a custom field and email it to below product name
<?php
/**
* Display the custom text field
* @since 1.0.0
*/
function cfwc_create_custom_field() {
$args = array(
'id' => 'custom_text_field_title',
'label' => __( 'Product Name In Thai', 'cfwc' ),
'class' => 'cfwc-custom-field',
@akshuvo
akshuvo / class-wc-query.php
Created May 6, 2019 21:38 — forked from saimonh3/class-wc-query.php
Sort product by popularity with price greater than zero
add_action( 'woocommerce_product_query', function( $qeury ) {
if ( empty( $qeury->query_vars['orderby'] ) || 'popularity' !== $qeury->query_vars['orderby'] ) {
return;
}
add_filter( 'posts_clauses', function( $args ) {
$args['orderby'] = ' CASE wc_product_meta_lookup.min_price WHEN 0 THEN 1
ELSE -1
END ASC, wc_product_meta_lookup.total_sales DESC, wc_product_meta_lookup.product_id DESC
';
@akshuvo
akshuvo / ThzelGetElementSettings.php
Created May 22, 2019 08:32 — forked from danyj/ThzelGetElementSettings.php
Pull any Elementor options outside of Elementor
/**
* @package Thz Framework
* @author Themezly
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
* @websites http://www.themezly.com | http://www.youjoomla.com | http://www.yjsimplegrid.com
*/
class ThzelGetElementSettings {
@akshuvo
akshuvo / Create a post WP REST API with Framework7.js
Created June 1, 2019 15:11
Create a post WP REST API with Framework7
// Create post WP REST API with Framework7
app.request({
url: 'https://example.com/wp-json/wp/v2/posts',
dataType: 'json',
crossDomain: true,
contentType: 'application/json',
data: {
title: 'The title for the object.',
content: 'The content for the object.',
status: 'publish',