In some circumstances there are benefits to displaying visitor’s IP addresses inside certain WordPress pages and posts. If a potentially malicious visitor decides to visit your WordPress website, they will most likely see that their IP address has been identified and will consider their actions. There is a WordPress function snippet which will allow you to display user and visitor IP addresses using the shortcode [ user_ip].
Copy and paste the snippet below into your theme’s functions.php file
function display_user_ip() { $ip = $_SERVER['REMOTE_ADDR']; return $ip; } add_shortcode('user_ip', 'display_user_ip');
Use shortcode: [ user_ip] in pages and post or include the use of shortcodes in template files and widgets. To properly use the shortcode remove the leading space.
Source: http://botcrawl.com/how-to-display-user-and-visitor-ip-addresses-on-wordpress-using-shortcodes/