Using Output Buffer in Shortcode

If you’re using a shortcode to display a customize content with lots of HTML tags output buffering is your tool. It’s a common Issue when using a shortcode is we echo it’s output, in return the output doesn’t follow the layout of the builder.

function display_me_properly_callback(){
  ob_start();
  ?>
  <h2>Hello</h2>
  <p>This is a test.</p>
  <?php
  return ob_get_clean();
}
  
add_shortcode("display_me_properly","display_me_properly_callback");

Using Add Filter

This will be a simple snippet to show the usage of add_filter() in WordPress. I will show you how you a simple usage of this powerful WordPress hook!

function rda_hello_world_callback(){

	echo  apply_filters( 'rda_hello_text', "Hello world!" );

}

Then here's the snippet to modify our message in the shortcode.

function rda_hello_text_callback( $text ) {

	$text = $text . ' Good morning!';

	return $text;

}

add_filter( 'rda_hello_text', 'rda_hello_text_callback' );

Now if you're done with it, our output would be like this.

Hello world! Good morning!

Eat that frog, I meant your hardest task.

Yes, I know a frog an amphibian. Something that you wouldn’t even dare to touch. Same way you think about that task you don’t even bother looking at.

Mark Twain has this famous quote.

“If the first thing you do each morning is to eat a live frog, you can go through the day with the satisfaction of knowing that that is probably the worst thing that is going to happen to you all day long.”

I learned about him in one of  Brian Tracy’s article. The frog is your task, you gonna deal with it no matter what or it’s just going to stay in your pending list forever along with the other ones who are also lost in the abyss.

Incorporate it into a habit ,  whenever you wake up do it first in the morning. Use a smartphone or any tool to track your progress. Having that feeling of accomplishing that hardest task that you’re stressing about is one of the most satisfying things you could achieve.

I hope you enjoy my blog! It would really help if you give me a feedback, I’ll really appreciate it. Submit feedback

Using Reddit to Improve

Reddit, our procrastination buddy, the place where we always get drowned in its fun stuff. There’s a lot of stuff you could find there, a subreddit catered for your personal preference.

With that given, there’s also a bunch of subreddit catered for personal growth, also reddit greatly influence me that’s why I’m able to blog  Smartphone Minimalism and turning goals into habits.

With that said I’m going to share with you a brief overview of subreddits that will greatly improve your way of life and hopefully increase your productivity. Take your time and check each subreddit which will greatly help you.

My Top 5 Subreddits

1. r/getdisciplined/ –  If you want advice to stop a bad habit and start a good one redditors here respond very quickly.

2. r/selfimprovement/ – Subreddit for people who want to improve. Pretty straightforward, redditors here will provide you tips and advice on how you can grow that skill.

3. r/howtonotgiveafuck/ – If you want to let go of that fear, be daring and know what you can be, this active community is yours.

4. r/productivity/ – Ok you have a deadline you wanna meet? Join this group. Lots of tips and workflows you can learn if you join this community.

5. r/Frugal/ – I personally like this group, if you want to improve your relationship with money you need to join this community.

I hope you enjoy my blog! It would really help if you give me a feedback, I’ll really appreciate it. Submit feedback

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.

  • http://www.tristanharris.com/2016/01/distracted-in-2016-welcome-to-mindfulness-bootcamp-for-your-iphone/
  • http://stopandbreathe.com/2011/06/03/six-steps-to-a-minimalist-iphone-or-smart-phone/
  • http://www.businessinsider.com/minimalist-iphone-home-screen-2017-1

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.
https://gist.github.com/raiden808/c08cf4e2b01ae21123ad23ce6809bb71

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.