Series: WordPress Tutorials (General)

How to Add Ads after Read More Tag in WordPress

ads-after-more-tag

Today, this site finally reaches a new milestone, 500+ page views/day. Even though it’s very low, I decided to add ads in this blog.

This blog uses full content in archive, and I’m breaking long content using manual “read more tag” (not using excerpt).

Note: You can add more tag using the editor toolbar or using <!--more--> in text editor.

I want to add the Ads in all blog post after read more tag, so technically when visitor click the read more, they will see ads on the top of the page.

It’s tricky because when we use the_content filter, WordPress already transform <!--more--> tag into HTML tag, something like <span id="more-1325"></span>. Here’s the code:

Read More How to Add Ads after Read More Tag in WordPress

How to Add WordPress CPT Admin Menu as Sub Menu

cpt-menu-as-submenu
f(x) Photo Tag Admin Page

When I write f(x) Photo Tag plugin, I think it’s best to put the menu under “Media” because it’s simpler, and also make sense.

Sometimes we want to add custom post type admin menu as sub-menu item on other post type or under settings page, because it make sense (not all post type need to be parent menu), and I like this approach because it make WordPress Admin cleaner.

And Here’s how I do that:

Read More How to Add WordPress CPT Admin Menu as Sub Menu

My Contact Form 7 Tips & Hack

cf7-banner

Contact Form 7 is my preferred contact form in most site, It’s free, light weight, and easy to use. It’s full of awesomeness.

Here are several tips for Contact Form 7 user that I use regularly.

Read More My Contact Form 7 Tips & Hack

How to update get_currentuserinfo() for WordPress 4.5+

In one of my plugin, f(x) Profile Dashboard Widget, I use get_currentuserinfo() to get current user data, apparently it’s deprecated in WP 4.5.

Here’s the code I use to replace it with wp_get_current_user(): while maintaining backward compatibility.

Previous Code:

global $current_user;
get_currentuserinfo();

New Code (WP 4.5):

if( function_exists( 'wp_get_current_user' ) ){
    $current_user = wp_get_current_user();
}
else{
    global $current_user;
    get_currentuserinfo();
}

How To Remove WordPress Admin Color Scheme Option

Admin-Color-X

Well, there was a time when I need to remove admin color scheme option. And this how I do that.

I was building a complex site with several user role, and to make it easier to know which user role I use to login, I set each user role to use different admin color scheme and disable admin color option in profile edit.

It’s actually pretty simple. And I will also explain the coding process, how to learn to code something in WordPress. (I’m sure it’s pretty useful trick if you wants to learn to code/problem solving in WP). Read More How To Remove WordPress Admin Color Scheme Option

How to Create Admin Notice On Plugin Activation

plugin-activation-notice-example

Adding admin notice on plugin activation can be super useful. For example we can:

  • Add link to the settings page,
  • Giving info about minimum requirement of their server,
  • Tutorial links,
  • Promote pro version of our plugin,
  • Ask the user to rate our plugin,
  • Ask donation,
  • Or simply telling them that they are awesome.

If you ever try to create an “Admin Notice” on plugin activation. You’ll know that using admin_notices action inside your “activation hook function” will not work. But there’s a workaround for that. Read More How to Create Admin Notice On Plugin Activation

How To Disable WP.org Theme Update Check

WP.org is not very good (read: evil) organization. They collect data without user consent, they are not transparent in what data they collecting, and they make it hard to disable this.

For example: There’s no easy way to exclude custom theme for update check. WordPress have filters for everything, but they don’t have this filterable. Maybe they want to monopolize theme market (maybe they are trying to say: you want to create theme? you need to use wp.org theme repository).

The only way to disable theme update check to wp.org repository is using this code (well, it’s pretty much a hack): Read More How To Disable WP.org Theme Update Check

How to Host WordPress in Digital Ocean VPS (Step by Step Tutorial)

A simple walk-through in how we can host our WordPress site(s) in Digital Ocean (un-manage VPS) Cloud Server. Using Ubuntu and LAMP.

Introduction

digital-oceanThere’s a lot of WordPress hosting out there, and the price is affordable. But recently several developer friend at Theme Hybrid community shared that they move to Digital Ocean because of several reasons:

  • Better server (response time, ssd storage, bandwidth) than shared hosting
  • Dedicated IP for each droplet
  • Simple interface/easy to use (for a unmanaged vps)
  • Simple backup and we can create snapshot of our server
  • Easier to scale when we need
  • Amazing price, start at $5/month
  • Charged per hour usage, so we can easily create a test site (for clients) and destroy it when we no longer need it.

Read More How to Host WordPress in Digital Ocean VPS (Step by Step Tutorial)

Disable Sidebar and Widget Without Plugin

Sometime we need to disable sidebar / widget area conditionally, The most popular option is to use Widget Logic Plugin, or you can try my plugin: Atomic Widget. But if you prefer manual way, maybe for client site where you don’t want to confuse them with extra settings in widget you can do this easily with this code. Read More Disable Sidebar and Widget Without Plugin