Skip to content

Instantly share code, notes, and snippets.

View Niloys7's full-sized avatar
🏠
Working from home

Niloy Niloys7

🏠
Working from home
View GitHub Profile
@Niloys7
Niloys7 / equalWidth.js
Created October 25, 2015 06:46
Get Equal Width for element base on parent element
var total = 0;
$('.ClassName').each(function() {
total+= $(this).width();
total+= parseInt($(this).css('margin-left'), 0);
total+= parseInt($(this).css('margin-right'), 0);
total+= 0;
});
var num_blocks = $('.ClassName').size();
@Niloys7
Niloys7 / replace-wp_submit.php
Last active October 24, 2023 13:43 — forked from zutigrm/replace-wp_submit.php
Replace submitdiv in custom post type
<?php
/*=========================================
Custom Submit Box
==========================================*/
/**
* Loop throught custom post types and
* replace default submit box
*
* @since 1.0
*
@Niloys7
Niloys7 / TiggerOnScroll.js
Created November 15, 2015 03:33
Trigger action when a user scrolls past a certain part of the page
$(window).scroll(function() {
var y_scroll_pos = window.pageYOffset;
var scroll_pos_test = 500;
// set to whatever you want it to be
if(y_scroll_pos > scroll_pos_test) {
$("body").css("background-color","#000");
}
else
{
@Niloys7
Niloys7 / getgalleryimage.md
Last active August 2, 2026 16:53
How to Get WooCommerce Product Gallery Images Programmatically (PHP)

How to Get WooCommerce Product Gallery Images Programmatically (PHP)

Need to retrieve WooCommerce product gallery images in your theme or plugin? This guide shows how to get all gallery image URLs and image HTML for a WooCommerce product using PHP.

Whether you're building a custom product gallery, API integration, slider, or image export tool, this snippet will help you access every gallery image attached to a product.

Get WooCommerce Product Gallery Images

<?php
// Display Taxomonies
$terms = get_terms( 'fw-portfolio-category' ); // Taxomony Name
foreach ( $terms as $term ) {
// The $term is an object, so we don't need to specify the $taxonomy.
$term_link = get_term_link( $term );
// If there was an error, continue to the next term.
if ( is_wp_error( $term_link ) ) {
<?php
/*
http://manual.unyson.io/en/latest/options/introduction.html#content
*/
$options = array(
'tab_1' => array(
'title' => esc_html__('Logo Options', 'academic'),
'type' => 'tab',
'options' => array(
'heading' => array(
{
"plugins": [
"query-monitor",
"regenerate-thumbnails",
{
"slug": "envato-theme-check",
"source": "https://github.com/envato/envato-theme-check/archive/master.zip"
}
@Niloys7
Niloys7 / porto-theme-quickview.php
Last active December 29, 2020 11:19
Since Porto theme has there owned gallery markup that reason the quick view feature is not working properly with the "product gallery slider" . so we need to override the ajax function only for the quick view mode.to do this just copy the code from below and paste it into your child-theme/functions.php or create a custom plugin to add this code.
<?php
add_action( 'init', 'cix_new_hooks');
function cix_new_hooks(){
remove_action( 'wp_ajax_porto_product_quickview', 'porto_product_quickview' );
remove_action( 'wp_ajax_nopriv_porto_product_quickview', 'porto_product_quickview' );
add_action( 'wp_ajax_porto_product_quickview', 'cix_porto_product_quickview' );
add_action( 'wp_ajax_nopriv_porto_product_quickview', 'cix_porto_product_quickview' );
}
@Niloys7
Niloys7 / dcpt.php
Created April 17, 2021 12:44
//Delete all posts of a custom post type with its included post meta data and taxonomies by using wpdb
function deletePostType($postType = ''){
global $wpdb;
$result = $wpdb->query(
$wpdb->prepare("
DELETE posts,pt,pm
FROM {$wpdb->prefix}posts posts
LEFT JOIN {$wpdb->prefix}term_relationships pt ON pt.object_id = posts.ID
LEFT JOIN {$wpdb->prefix}postmeta pm ON pm.post_id = posts.ID
WHERE posts.post_type = %s
@Niloys7
Niloys7 / functions.php
Created August 9, 2021 20:04
Update preorder date programmatically for Variable products
add_action('wp_head','bp_preorder_script');
function bp_preorder_script() {
$args = array(
'post_type' => 'product_variation',
'posts_per_page' => -1,
);
$query = new WP_Query( $args );