Skip to content

Instantly share code, notes, and snippets.

@ali-cedcoss
Created April 9, 2022 08:34
Show Gist options
  • Save ali-cedcoss/8a5280894feaef00effe4360e6ffd79f to your computer and use it in GitHub Desktop.
Save ali-cedcoss/8a5280894feaef00effe4360e6ffd79f to your computer and use it in GitHub Desktop.
get all custom product attributes from db
			global $wpdb;
			$query = $wpdb->get_results($wpdb->prepare("SELECT `meta_value` FROM  {$wpdb->prefix}postmeta WHERE `meta_key` LIKE '_product_attributes'"), 'ARRAY_A');
			foreach($query as $key => $db_attribute_pair){
				foreach(maybe_unserialize($db_attribute_pair['meta_value']) as $key=>$attribute_pair){
					if(1 != $attribute_pair['is_taxonomy']){
						print_r($attribute_pair['name']);
						echo '<br>';
					}
				}
			}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment