WordPress: Action Hooks vs. Filter Hooks

In WordPress, hooks are the building blocks for your themes and plugins and are vital for their functionality. Basically, their purpose is to allow developers to make their own custom code (and custom functionalities) to themes or plugins without changing any of the original WordPress files. There are two types of hooks that exist in WordPress: action hooks and filter hooks.

Action Hooks
Action hooks are hooks that (this may be obvious) trigger an action. They can be inserted at certain points within your code to carry out actions by loading different custom functions from within your WordPress theme. To use an action hook, create a function or choose one of the functions in your functions.php file, and hook that function into your code by using the add_action() function. Here’s the syntax for using an action hook:

add_action( $hook, $function_to_add, $priority, $accepted_args );

Filter Hooks
Filter hooks are used to manipulate outputs or add particular content to certain loops to make an output appear after a trigger or after a certain type of content. For example, you can use filter hooks to ensure that a particular output (a link, a line of text, a footer) will appear after every instance of a particular type of content, like blog posts for example. This can be achieved by using the add_filter() function.

add_filter( $tag, $function_to_add, $priority, $accepted_args );

Use MAMP to Install WordPress on Your Local Machine

If you’re a WordPress developer then you probably know how much quicker and easier it is to develop a theme or create a new WP site on your local machine rather than doing so on a remote server. The only slight problem with building a theme locally is that you can’t run PHP on your local browser — it’s just not supported. Fortunately, we can use MAMP to easily and efficiently create a local PHP server on your machine.

icon-mamp

The steps to setting up your server are simple. Once you’ve installed MAMP, configure your settings as follows:

  • Make sure that your ports are configured to 8888 (you’ll access your server from localhost:8888), to do this click preferences and then ports from the main MAMP dashboard
  • Set your server’s document root (under the Web Server tab) to the directory that contains your WordPress install. If you have it set to another file or directory, you won’t be able to use MAMP to access your WP site.

Now that your server is configured, it’s time to set up WordPress. Click “start” on your MAMP dashboard. Set up your database by clicking the phpMyAdmin link and selecting “create new database.” Give your new database any name of your choosing.

To actually run your WordPress site, go to localhost:8888 and enter the following information into the fields you’ll find on your local server’s home page:

Database Name: yournewdatabasename
User Name (database): root
Password (database): root
Database Host/server: localhost
Table Prefix: wp_

That’s all you need to do to set up your site. Now all that’s left to do is to get to work.

How To Install Nginx Webserver On Ubuntu 16.04

Nginx is a great web server. I am using it on other blogs I owned online. It’s probably the second most popular web servers in used today.. and growing rapidly.

Some will argue that Nginx is more resource-friendly than Apache2 and can be used as a reverse-proxy server.. so it’s pretty good.

This brief tutorial is going to show you how to easily install Nginx web server in Ubuntu 16.04.

Continue reading “How To Install Nginx Webserver On Ubuntu 16.04”

How To Install Let’s Encrypt Certificates On Ubuntu Server With Apache2

I recently had to install Let’s Encrypt certificates on one of my websites hosted on a Ubuntu server running Apache2 web server.

The process was painless and easy.. and this brief tutorial is going to show you what steps I took and what to look out for when installing one yourself.

If you don’t already know, Let’s Encrypt allows anyone to obtain and install their trusted SSL certificates for free on their websites.

Continue reading “How To Install Let’s Encrypt Certificates On Ubuntu Server With Apache2”

Change WordPress Admin Password and Email from Database

This brief tutorial shows you how to easily and quickly change WordPress admin password and email address from its database.

The reason I’m writing this is I ran into a minor issue where I lost control of my admin account.. not due to hackers or someone who deliberately took over my account.

A user who knew and had access to the admin account email requested a password change… the password help email was sent and password reset by the user.

Continue reading “Change WordPress Admin Password and Email from Database”