Ip2location plugin in my template header?
I am using Ip2location plugin to pull state data based on Ip address into my post.
This is easy you install the plugin and then just use {ip:regionName} in the post or page editor.
But I want to print this information in my template header file right beside the title
is this possible and if so how do I go about this?
This is how the header php looks like in the template
?php
$def_header_text = esc_html__( 'This is Header Media Text.', 'cleanportfolio' );
if ( current_user_can( 'edit_theme_options' ) ) {
$def_header_text .= 'nbsp;' . esc_html__( 'Edit this from Appearance - Customize - Header Media - Header Media Text.', 'cleanportfolio' );
}
$header_media_text = get_theme_mod( 'cleanportfolio_header_media_text', $def_header_text );
if ( is_front_page() ( has_custom_header() || '' !== $header_media_text ) ) : ?
div class="custom-header"
?php
if ( has_custom_header() ) : ?
div class="custom-header-media"
?php the_custom_header_markup(); ?
/div
?php endif; ?
div class="custom-header-content sections header-media-section"
?php if ( '' !== $header_media_text ) : ?
h2 class="section-title"?php echo esc_html( $header_media_text ); ?/h2
?php endif; ?
/div
?php if ( ! has_custom_header() ) : ?
div class="square"?php echo cleanportfolio_get_svg( array(
'icon' = 'square',
) ); ?span class="screen-reader-text"?php esc_html_e( 'Square', 'cleanportfolio' ); ?/span/div
?php endif; ?
/div!-- .custom-header --
this is how ip2location says to use there service in PHP
https://www.ip2location.com/developers/php
I am not a full time coder any example on how to may be try will be very helpful.
Error on cell Phone data
Thank you for your advise @nmr, I found quite a bit of bugs on other plugins so I decided to fix them to see if it would make ip2location work but it didn't.
Wifi / ethernet Connection: (This works great)
2018-08-31 17:39:53 Lookup by BIN database.
2018-08-31 17:39:53 Geolocation result for [66.219.198.137] found: Array
(
[ipNumber] = 1121699465
[ipVersion] = 4
[ipAddress] = 66.219.198.137
[countryName] = United States
[countryCode] = US
[cityName] = Lehi
[regionName] = Utah
)
Cell Phone LTE Data Connection: (This Dosen't work )
2018-08-31 17:40:04 Lookup by BIN database.
2018-08-31 17:40:31 Lookup by BIN database.
2018-08-31 17:40:31 Geolocation result for [127.0.0.1] found: Array
(
[ipNumber] = 2130706433
[ipVersion] = 4
[ipAddress] = 127.0.0.1
[countryName] = -
[countryCode] = -
[cityName] = -
[regionName] = -
)