Sample useful WordPress shortcodes – show Google ad snippet, user’s IP address, current time

Here are a few more useful WordPress shortcodes.  Simply copy the code and paste it into your active theme’s “function.php”.

You can call on shortcodes with the square brackets inside your post or pages:

Insert a Google ad snippet, horizonal 720 x 90 pixels:

[insert_script path='/library/vendors/google/ads/horiz-720x90.php']

Show computer’s IP address:

[[show_ip]] — produces:  [show_ip]

/* Allows insertion of external PHP scripts easily into pages, posts & widgets.
* "vars" is query string that will be parsed by script in a variety of ways,
* Most useful is parse_str()  where ?x=1&y=3 will parse into script as $x=1, $y=3
function insert_script($atts){

extract(shortcode_atts(array("path" => '',"vars"=>''), $atts));
return ob_get_clean();

add_shortcode('insert_script', 'insert_script');

// Shows current Date and Time
function todays_date_time($atts){
return date("Y-m-d H:i:s");

// Shows computer's current IP address
function show_ip(){


About Author:

Senior Cloud Software Engineer and 25+ years experienced video production, video editing and 3D animation services for a variety of global clients including local video production here in Jacksonville, Florida.

Leave a Comment

Your email address will not be published. Required fields are marked *