Skip to content

Instantly share code, notes, and snippets.

View abidkakkur11's full-sized avatar
🎯
Focusing

Abid KP abidkakkur11

🎯
Focusing
View GitHub Profile
@abidkakkur11
abidkakkur11 / enable_descriptions_product_list_page.php
Created May 13, 2026 11:16
This snippet will add short description and description on the woocommerce all products page
<?php
// Add Description & Short Description columns to WooCommerce product list
add_filter( 'manage_product_posts_columns', function( $columns ) {
$columns['short_description'] = __( 'Short Description', 'woocommerce' );
$columns['full_description'] = __( 'Description', 'woocommerce' );
return $columns;
});
add_action( 'manage_product_posts_custom_column', function( $column, $post_id ) {
$product = wc_get_product( $post_id );
@abidkakkur11
abidkakkur11 / enable_descriptions_product_list_page.php
Created May 13, 2026 11:16
This snippet will add short description and description on the woocommerce all products page
<?php
// Add Description & Short Description columns to WooCommerce product list
add_filter( 'manage_product_posts_columns', function( $columns ) {
$columns['short_description'] = __( 'Short Description', 'woocommerce' );
$columns['full_description'] = __( 'Description', 'woocommerce' );
return $columns;
});
add_action( 'manage_product_posts_custom_column', function( $column, $post_id ) {
$product = wc_get_product( $post_id );
@abidkakkur11
abidkakkur11 / widget_for_woocommerce_brands_grid.php
Created December 3, 2025 08:18
Snippet for displaying WooCommerce brands taxonomy in a grid format using shortcode
<?php
/**
* Shortcode: [wc_brands_grid_styled]
* Usage: [wc_brands_grid_styled cols="6" cols_tablet="3" cols_mobile="2" hide_empty="true" limit="0" show_count="true"]
* Put this in a snippet plugin (Code Snippets, WPCode, etc.) and activate.
*/
add_shortcode( 'wc_brands_grid_styled', function( $atts ) {
// attributes
$atts = shortcode_atts( array(
@abidkakkur11
abidkakkur11 / total_product_count_woocommerce_backend.php
Created December 3, 2025 08:14
Display Total products count including variations on the backend "All Products" pages on WooCommerce
<?php
// Show total product + variation count in WooCommerce Products dashboard
add_action( 'manage_posts_extra_tablenav', function( $which ) {
global $wpdb;
if ( $which === 'top' && get_current_screen()->id === 'edit-product' ) {
// Count published products
$products_count = $wpdb->get_var("
SELECT COUNT(*)
FROM {$wpdb->posts}
@abidkakkur11
abidkakkur11 / order-page-by-modified-date.php
Created November 17, 2025 16:13
This snippet add a sort option according to the last modified date on WordPress admin side
<?php
// Add modified date column to posts and pages lists
function custom_modified_date_column($defaults) {
$defaults['modified_date'] = 'Modified Date';
return $defaults;
}
function custom_modified_date_column_content($column_name, $post_ID) {
if ($column_name == 'modified_date') {
$modified_date = get_post_field('post_modified', $post_ID);
$formatted_date = date_i18n('Y/m/d \a\t g:i a', strtotime($modified_date));
@abidkakkur11
abidkakkur11 / media-button-near-acf-field.php
Created November 17, 2025 09:13
Add A Media button near the ACF URL or any Field on Backend
<?php
add_action('admin_enqueue_scripts', function($hook) {
// Load only on product edit pages
if ( ! in_array( $hook, ['post.php', 'post-new.php'], true ) ) return;
if ( get_post_type() !== 'product' ) return;
// Load WordPress media scripts
wp_enqueue_media();
// Inline script
@abidkakkur11
abidkakkur11 / media-seo-updater.php
Last active November 14, 2025 04:08
This snippet adds an "Update SEO Details button" in all media modals, which update SEO alt and description from title - remove special characters and numbers
<?php
/**
* Media SEO Updater β€” Inline JS + AJAX save (single snippet)
* Paste into Code Snippets or theme/plugin. Runs in admin.
*/
add_action( 'admin_enqueue_scripts', function() {
// Ensure media scripts are available
if ( function_exists( 'wp_enqueue_media' ) ) {
wp_enqueue_media();
@abidkakkur11
abidkakkur11 / display-sale-percentage.php
Last active November 14, 2025 03:46
Displaying the sale percentage on the Woocommerce admin table
<?php
/**
* Add a custom column for displaying the sale percentage in the WooCommerce Products admin table.
*
* @param array $columns Existing columns in the Products table.
* @return array Modified columns with the Sale Percentage column added.
*/
function add_sale_percentage_column_to_products( $columns ) {
// Add a new column for Sale Percentage
$columns['sale_percentage'] = 'Sale Percentage';