How to Display Users’ IP Addresses in WordPress

How to Display Users’ IP Addresses in WordPress

An IP address, a string of unique numbers, shows users’ location where the information should be sent by servers. IP addresses work as connections for users to access information every time they perform online activities on your WordPress site. In this article, we will show you how to display Users’ IP Addresses in an easy way.

With IP addresses, you can decide who has the access to your website, tailor how your website responds to requests on the basis of users’ location or other criteria, analyze what content your users will have an interest in, and many more.

Anyway, it is an easy job to display users’ IP addresses on your WordPress site. By using code or plugin, your users will have their own IP address when they land on your website.

Display Users’ IP Addresses in WordPress with Code

You may take it for granted that you cannot deal with code for the fear of messing up your website. Therefore, you should create a child theme from the beginning to reduce the risk. On one hand, your changes will be saved even when the parent theme is updated. On the other hand, you can customize the child theme in the way you like without any impact on your parent theme.

Having created a child theme, just add the below code into your child theme’s function.php file.

Add Code

Then you can put the below shortcode in a place where you want to display users’ IP addresses.

Show IP with Shortcode

Display Users’ IP Addresses with Plugin

For your convenience, you’d better give preference to rely on a plugin named Show IP address which will help you clearly show IP addresses of the website visitors.

Step 1: Access Show IP address

There are two methods available for you to access Show IP address: install manually or install directly. The first method requires you to download the file, unzip it, upload it to your plugins folder via FTP, and then activate the plugin on the result screen of Plugins > Installed Plugins.

However, you can download Show IP address directly from WordPress Plugin Directory, which saves you much time and energy. There are many free and open source plugins available in WordPress Plugin Directory. All you need to do are to land on the Plugins > Add New page, search for Show IP address, and press the Install Now button. After activation, there is no need for you to configure the plugin.

Show IP address

Step 2: Display Users’ IP Addresses with the [show_ip] Shortcode

Just enter the shortcode [show_ip] into a Text Widget on the Appearance > Widgets page. If everything goes well, you will display users’ IP addresses in your sidebar area.

Text Widget

If you fail to add the additional functionality to a text widget, you can follow this tutorial to enable shortcodes in text widgets. The reason lies in that the default WordPress filters do not allow shortcodes to execute.

Note: There are some instances when you need to block malicious IP addresses to protect your WordPress site from potential dangers. So be sure to track your users’ IPs.