Add Attribute to WooCommerce Product Programmatically

In the world of web development, anything can happen, for instance and the sake of this article, let’s say you’re working with a team utilizing git and for some reason all attributes of a given product have gone missing and your task is to get these attributes back to where they were.  You could do this manually, but why not dive into some code and replace those missing attributes?

Step 1: Get all products and store in an array

        global $product;
	$taxonomy = 'pa_greeting-card-type';
	$term_name = 'holiday';
	$term_slug = sanitize_title($term_name); // The term "slug"
	$product_ids = [];
	$args = array(
		'post_type' => 'product',
			'posts_per_page' => 70,
			'tax_query' => array(
					'taxonomy' => 'product_tag',
					'field' => 'slug',
					'terms' => array('mothers-day-card', 'valentines-day-card', 'christmas-cards', 'holiday-card', 'new-year-card', 'jewish-card', 'easter-cards', 'new-year' 

	$loop = new WP_Query($args);
	while ($loop->have_posts()) : $loop->the_post();
			global $product;
			$flag = 0;
			// get product attributes
			$attributes = $product->get_attributes();
				$product_ids[] = get_the_ID(); //products with no attributes
			// if it has product attributes
			else {
				//looping through all product attributes
				foreach($attributes as $attribute) :
					 echo $attribute['name'];

					if($attribute['is_taxonomy']) {
						if($attribute['name'] == $term_name){
							$flag = 1;
				if ($flag != 1) {
					$product_ids[] = get_the_ID();  //products from our loop without our missing attributes


Step 2: Loop through products adding our missing attribute

$product_ids will contain all the Product IDs which do not have our missing attribute, so now we can loop through and set that missing attribute.

		foreach ($product_ids as $product_id) {
		// Check if the term exist and if not it create it (and get the term ID).
		if( ! term_exists( $term_name, $taxonomy ) ){
		    $term_data = wp_insert_term( $term_name, $taxonomy );
		    $term_id   = $term_data['term_id'];
		} else {
		    $term_id   = get_term_by( 'name', $term_name, $taxonomy )->term_id;

		//Initialize new object
		$product = wc_get_product( $product_id );

    	        $attribute = new WC_Product_Attribute();
		$attributes[] = $attribute;



		// Append the new term in the product
		if( ! has_term( $term_name, $taxonomy, $product_id )) {
		    wp_set_object_terms($product_id, $term_slug, $taxonomy, true );

Step 3: Go kiss your loved ones, you’re done here


Please feel free to comment and let you know if this got you on the right track!

How to migrate to the WP Engine staging environment

[vc_row][vc_column][vc_column_text]In it’s 16th year, WordPress is still leading the pack when it comes to a versatile CMS.  A clear indicator of how powerful and dominant the platform has become is the advent of hosting companies offering specialized managed hosting specifically for the WordPress CMS.  The leading host in this growing market by many of our metrics is WP Engine.  A major feature of WP Engine hosting has been the ease in which sites of any size can be migrated over to the WP Engine servers.  The migration process to WP Engine is simple and straightforward, however you may not be aware of a very cool feature that we’re sure will come in handy on your future or present WordPress projects.


If you are familiar with the WP Engine migration plugin, you will be aware that you can migrate easily to the production environment over at WP Engine, but did you know you can do EVEN MORE?  This is a simple step-by-step explanation of how you can migrate a site not to the main production server/environment, but to a WP Engine Staging environment as well. This can be clutch when the available installs on your account become filled up but you still need the powerful features and reliability of WP Engine to ensure a fast and smooth work flow.


A Brief History


Website migration is complex and difficult which is why WP Engine has developed their migration plugin for WordPress which automates the process and takes out the labor-intensity. In addition to providing an efficient migration solution for developers, WP Engine maintains an impeccable customer experience with unlimited monthly data transfers, daily backups, malware scanning, and 24/7 technical support.


The process


Step 1: Install ‘WP Engine Automated Migration Plugin

Go to your WordPress Dashboard and download ‘WP Engine Automated Migration’ plugin by following the pathway: ‘Plugin’ > ‘Add new’ and searching for “WP Engine Automated Migration”.


Step 2: SFTP Credentials

NOTE: You will need to already have a staging environment created; you can find how to create the environment here.  Once the plugin has been downloaded, select the ‘Site migration’ tab from your WordPress Dashboard.  You will notice a set of credentials you need to supply.  You can fill in your email address immediately, but to generate the rest of the information, you must login to your account on the WP Engine User Portal.

Note: if your current host or WP Engine environment is password protected, you will need to enter that information so the plugin can access everything for migration.


Step 3: Website Migration

In order to migrate to the WP Engine staging environment of your website simply fill in the staging environment url you created for your website.  The staging URLs are formatted as, fill in the remaining information, your SFTP address, username and password into the WP Engine migration plugin.


Once you have filled in all of the information correctly, select ‘Migrate’ on the plugin.  If you have followed the steps correctly and provided accurate credentials the migration will begin.   You will be redirected to the BlogVault Dashboard where you can access real-time updates of the process.  The time taken depends on the size of your website.


Step 4: Bask in the glory of a job well done


All done! You now have expanded the usability of the WP Engine staging environment. Visit your newly migrated staging site at



Sending Emails From Local With Postfix and MAMP

[vc_row][vc_column][vc_column_text]If you’re anything like me, you love to work locally building websites without relying on a live server, but this can present some drawbacks such as limiting the full functionality of your site, specifically, the ability to test outgoing emails.  In this post I will show you how to take your development even further and without bounds by enabling the ability to send emails from local with Postfix.[/vc_column_text][vc_column_text]I use MAMP Pro which comes packaged with postfix, however I needed some additional tweaks to get it going smoothly.  I tried many different ways to make postfix work out of the box with MAMP, but alas I was unsuccessful.  A major bummer, because has a “lazy developer” I like the easy straightforward approach as much as the next dev.


 Step 1. Setting up a working Postfix MAMP configuration

[vc_column_text]These instructions are working for me on OS High Sierra with MAMP version 4.4.1

Open the terminal and enter the following command

$open /var/log/mail.log

This will open the mail log console where you can follow along for warnings and errors.

Open the file /etc/postfix/ in your favorite editor

$open /etc/postfix/

  • Add the following lines at the bottom of the file.

relayhost = []:587
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_mechanism_filter = plain
inet_protocols = ipv4
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_security_options =
smtp_tls_security_level = encrypt
tls_random_source = dev:/dev/urandom

Step 2. Create then edit the sasl_passwd file to allow authentication with your Google Account

[vc_column_text]Enter this command in terminal:

$sudo vi /etc/postfix/sasl_passwd


Add the following lines

[]:587 [email protected]:yourpassword[/vc_column_text]

Step 3.  Enter the following commands to restart postfix

[vc_column_text]$sudo chmod 600 /etc/postfix/sasl_passwd
$sudo postmap /etc/postfix/sasl_passwd
$sudo launchctl stop org.postfix.master
$sudo launchctl start org.postfix.master
$sudo postfix upgrade-configuration

Next, reload Postfix.
$sudo postfix reload
$sudo postfix flush

Test that the configuration is working

$date | mail -s testing [email protected][/vc_column_text]

Step 4. Bask in the glory of your accomplishment.

happy Okoye[/vc_column][/vc_row]

Source Molecular Site Launch

New Site: Source Molecular provides analysis and treatment of fecal contamination from a wide variety of sources.

About Source Molecular: Source Molecular offers state of the art resources to combat and solve pathonegenic contamination of water. The new site features a brand new design, live chat and a pricing calculator allowing for a quick estimate.

50 Awesome Free WordPress Web Design Resources for Your Next Project – ThemeIsle Blog

Having access to free WordPress web design resources is a real life saver. So much goes into creating and running a quality site, from code and images to background graphics, fonts, icons and other elements. Not to mention the knowledge necessary to put it all together.


Imagine you had to pay for all of that! How ironic would it be to use a free CMS to run your site and then go broke over making it the best it can be? Thankfully, with the amount of free stuff out there, it doesn’t have to be that way.


In this article, we have compiled a boatload of free WordPress web design resources. With their help, you can build an awesome site or improve your existing one and still pay rent on time….

Sourced through from:

Is WordPress Still the Best?

I am a huge fan of WordPress. I’ve run my business on it for a decade, recommended it to thousands and feel eternally grateful for what it’s allowed me to do. But is it still the best option? As you might have noticed, the blogging scene has changed a lot in the last five years. There’s free platforms like Tumblr and Medium that are now absolutely booming and doing things slightly differently. Squarespace, the ultra-sexy hosting service (and podcast industry mega-patron!) is everywhere and is pretty awesome too. Then there’s the fact that a lot of people blog on social

Sourced through from:

WPEngine- WordPress Backups Made Easy


If you’re updating and making changes to your WordPress site, or any other site for that matter, there’s nothing more important than making  regular and complete backups in order to save all the painstaking effort you put into your business,  you should be backing up before you even think about making a single change anywhere, you should be backing up everything!

Creating  a backup may seem like a no brainer to some, but you would be surprised as to the number of website users, many of them seasoned veterans who simply don’t practice proper backup techniques.  Are you in the habit  of making a backup before you add any plugin no matter how lightweight to your WordPress installation?  If the answer is no then you fall into that woeful category of users not practicing routine and complete backups.

So why are backups and the issues related to creating a proper back up still a major thorn in the side of WordPress users?  One probable reason could be that backups can be at times cumbersome, and become even more so if updates are constantly being made to a WordPress site such as updating plugins, adding plugins, or adding custom code in the backend to say a function.php file.  That’s why I’m  excited to share the seemless, integrated and automated backup features offered byWPEngine hosting that comes standard with every hosting package.  WPEngine is by far our favorite shared hosting provider, we use it to run out business and recommend all our clients who utilize WordPress do the same.

Ease your mind, backups are always on time

With their daily snapshots you’re site’s data is guaranteed to be saved in it’s entirety up to 30 days. if you ever need to come back to a previous point due to any number of reasons.  Restoring is a breeze, simply one click and Poof your site is back to where it was, a notification email will alert you when complete.

Need to make a manual backup?  It’s also just one click away, click backup, give it a descriptive name even, just to keep things o a bit more organized, an example of what you could name your backup could be something like “backup before testing new custom function”,  set the notification email and sit back and wait for the alert.

wpengine backup notifications

What if you happen to make a mistake and restore to a backup point you didn’t mean to?  I recently did this by restoring  the wrong install.  I couldn’t believe it and I started to panic, but  WPEngine had me covered, before a restore is processed, the WPEngine backup takes a snapshot of your site at it’s current state.  A lifesaver if you ever happen to make the mistake of restoring when you did not intend to.

wpengine pre-restoration image

WPEngine even has a handy prompt whenever installing a new plugin that ask you if you backed up before the installation, if you didn’t you can simply click and have a backup created right away without having to navigatge out of your WordPress backend.

wpengine prompt

With all of these features, WPEngine keeps our peace of mind at an all time high.  Gone are the days of cumbersome manual backups, or clumsy backup plugins that simply did not function up to par, especially for larger sites.  Take advantage of the ease and simplicity WPEngine offers and focus on what really matters, running your business.

[/vc_column_text][/vc_column][/vc_row][vc_row][vc_column][mk_custom_sidebar sidebar=”sidebar-15″][/vc_column][/vc_row]