Smartphone Minimalism

I'm here to share with you another self-improvement technique that I've read and greatly affect the way I use my phone today. It's called "Smartphone Minimalism". Kinda weird right? Minimalism on a smartphone?

Well, I'm here to share with you how it changes the way I used my phone and also to provide you with a couple of blogs that gave a great impact on me.Smartphone minimalism for me in my own definition is the enhancing of the way we used our phone in our daily life.

Smartphone in a way is not just some social media or a procrastination machine that we used to burn much of our time. I think smartphones are more than that already, they are now a powerful tool to keep you accompany to achieve your goals in life depending on how you used it.

How could it accompany you to archive your goal? There like tons of apps out there waiting to be discovered that will help you towards your journey in life. Although you wouldn't appreciate that if first, you don't know how to use your smartphone in a productive manner.

Having that said I first encountered it myself around a year ago. The time where I have a lot of social media apps, games and other stuff. I feel like a slave to my phone, a major turning point in my life. I started looking for app detox(an app that could track your usage) and other productivity habit tracking apps. It's pretty easy to find an app for android which is kinda different on IOS though.

Before I share with you some blogs on how to use this said technique here a bit summarization on how to use it in my own approach.

Step 1. Select apps that you frequently use and put them on our home. Max of 4 only, for me I minimize it up to 2.

Step 2. Group all related apps on the single folder.My version since I’m lazy I group it into a single one and separate another folder for something that I’m interested in. Also, It’s important that the visually triggering app icons should be in the back and leave white/ grey coloured apps in front, as the more colourful the apps are the more it will be distracting.

Why use this setup?

This set up will utilize the power of the “Search” our consciousness filter, This was written by Tristan Harris. It’s very effective technique, he said that when we use typing when using an app instead of directly clicking it we are becoming “conscious” of what we are doing. By being “present” on using our smartphone we become smarter on how we use it, not just mindlessly clicking an app whenever we like which will turn 5 minutes scroll to 1 hour and so on.

The following are few of the blogs that help me be more aware of how to use my smartphone.


Grouping posts by month using post meta

In this snippet, I will show you how to do go grouping posts by month using post meta. Why? Sometimes you have a date field and within your custom fields especially for travel agency plugins and you kinda want to count how many bookings are made in each month.

This is very useful if you want to create search filter by date.

Here’s how I did it.

Notice that I’ve used an SQL script for this one? here’s some explanation about the parameters.

prefix – The table prefix will vary depending for the site owner. It could be ‘wp’ or ‘xp’ so in order to be safe use this parameter.

get_results – Is the type is an SQL function by WordPress to that returns the entire query result as an array. Whatever script you use that will be the result.

Get all products under a category

I’ve recently encountered a project that needs to get all products under a category. Creating my own product filter using ajax. So now I’m going to share to you a simple script on how to filter WooCommerce wp_query loop and retrieve all products under the category you have chosen.

You have to make sure that whenever you’re dealing with taxonomies you have to use tax_query

Tax query has these parameters needed to work but could be more once you started using multiple tax_query or nested tax_query. more info

taxonomy – The custom post type category you’re using. mine is product_cat which is the WooCommerce taxonomy.

field – Whether you’re gonna use slug or post id.

terms – The container array of your selected field.

Small things accumulate,power of tiny habits

Doing something but lost the motivation for it? A goal perhaps? that's something we all have in common. If the goal is too large we quit halfway, we lose motivation, experience burnout etc. I encountered this blogs that change my life and embrace tiny habits a new way to get your goal without feeling frustrated. Just a set of repetition is all you need.

A brief summarization about this blogs is that goals are a visual representation of what you want to achieve you want it but you don't know how to get started. It's overwhelming you. They are long-term and some people want's to achieve theirs in just one day and feel bad whenever they fail on doing so.

Habits are more of a systematic approach to doing your goal a ladder. You work on it daily and you get to improve on it as days gone by. What’s more is that you don’t need to have motivation on it you just need to build it up. Small things accumulate, small tiny steps matter.

Using specific WP_Query

A few weeks ago I encountered a task to retrieve an I.Ds with specific requirements of a hotel post type we're currently building. Instead of using an SQL script, I challenge myself to use WP_Query instead. Using specific WP_Query I was able to retrieve what I want.

Here's a brief introduction to WP_Query, It's commonly used to pull pages, posts and post types which if you wanted to create custom templates for your site. More details here.

Here's the snippet I used:

Using meta_query I was able to narrow than the results. I've able to retrieve events that is greater or equal to my selected date, which is another great alternative for SQL query.

Trigger append elements. How?

Have you ever got the need to trigger append elements? append() is mostly useful when you want to insert content or an element at the end of your target container. The common problems when you trigger append elements is that they are not rendered clickable.

Here is an example of an click() button :

The problem why you can't trigger this dynamically is because click() only applies for elements that already exists.
So you have to bind it to something that already exists such as the document.

Use wp_localize_script , It’s Amazing

Have you ever use wp_localize_script ?I'm going to share you a way to use PHP variable in javascript by using this amazing WordPress functionality. When you did this it enables your PHP code to be accessible on your registered script.

Here is a sample :

3 Important Parameters :

$handler - This the registered script that will handle the PHP variable that we attached to our javascript file.

$name - The name of our PHP variable container.

$data - This is mostly an Array if we want to attach multiple variables.

Example :

Shortcode specific scripts

Shortcode is a  powerful WordPress API, right?It allows us to enhance the front- end area of any website add custom functionality to it. In this snippet, I'll show you how to only run a certain script when you shortcode is in use. Which greatly increase our page speed.