Is there a way to tell which country you are in when viewing the site? I mean like is the domain name example.uk | example.ca | example.com/en … That kinda thing?
Then you could search your domain for the string for that country:
$protocol = stripos($_SERVER['SERVER_PROTOCOL'],'https') === true ? 'https://' : 'http://';
$url = $protocol . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
if (strpos($url,'/en/') !== false) {
echo 'English version';
} else if (strpos($url,'/us/') !== false) {
echo 'US version';
} else {
echo 'Not UK or US Version';
}
Related Posts:
- How to add a custom field in the advanced menu properties?
- Adding a custom field to the site identity menu
- Add meta data to the menu
- Create a select drop down of available menus
- Dynamic User State & City selection
- Creating a custom menu/widget area
- Nav Menu – Add class based on meta keys
- Add image to menu item with ACF
- Declaring in variables [closed]
- How to add a custom field in the advanced menu properties?
- Walker class for sub-menu with ACF fields
- Populate wordpress menu with link to custom field value (file download)
- Show Custom field value instead of title in WP Menu
- How to check custom fields from functions.php
- Override edit_custom_walker.php to conditionally show input depending on menu position
- How to use page metadata while using wp_list_pages()?
- Add custom fields to specific menus
- Add CSS class to posts with certain meta key
- Underscores in custom fields
- Add custom field to the archive page?
- Show only posts which can be commented OR have custom meta field
- Need small coding with Custom Fields Search
- Adding Custom Field to Taxonomy Input :Panel
- How can I remove fields in the attachment editor?
- Unable to get Preview of Uploaded image within a Custom Meta box
- Edit Custom Database Tables in WordPress
- How to store the value of a custom field dropdown select for post referencing?
- Custom bulk action for media gallery items
- Change content before writing to database
- post meta data clearing on autosave
- WordPress Search Custom Meta Field Only
- Localized Date Format for Custom Field
- Which is best in the following scenario : post_meta vs custom table vs parent/child posts
- Echo values from custom field outside loop php
- How to add content at the end of posts?
- Transfer self made functions.php custom fields to Advanced Custom Fields [closed]
- Complex WP_User_Query call fails on production server
- wordpress custom fields multiple data
- How do I define post titles as images using Custom Fields?
- How to show Small Box Inside Content Area, which holds (text, images, links)?
- Sort custom field by post
- How to create a gallery custom field for WordPress post?
- Why the pagination for a query modified by pre_get_posts doesn’t mind the number & order of posts sorted & selected based on a custom date time field
- Trying to update_post_meta function
- How do i add custom fields to my themes template file?
- Custom Field to a Role?
- List users by sum of all their posts’ custom field values
- Select multiple images from custom field
- Unique meta_key with array value vs repeated meta_key with single values
- Custom Field 101
- custom field (video/audio url) and embed functionality
- Allow only one post with specific meta value
- Querying posts by latitude and longitude to build a Google Maps with several markers
- How to display childrens custom fields?
- Attach images to posts using custom fields (just paths to images already uploaded)
- how to display custom fields of post on a web page
- Changed PHP handler to DSO – weird custom fields problem [closed]
- How to fill custom fields with brackets in their key with add_post_meta()?
- Is there a way to set default custom fields when creating a new post?
- Front-End User Profile
- Displaying pages with a specific custom meta
- How to update user profile custom fields
- put saved metabox values back into fields and then display on the front end
- Custom field to array?
- How to sort by custom field value?
- Meta Box Plugin Cloned Fields – Multiple Foreach values
- How to update custom field of a posts in a particular category
- How to query posts by month based on date custom field?
- Custom field bug in WordPress 3.2
- Change word in woocommerce product category custom field
- get posts based on non-single metadata
- Problem with revisions only returning four results
- How to save multiple values with same meta_key, each value linked to another tag id
- Add forms dynamically in admin pages?
- What WordPress “technology” would I use if I wanted subscribers to be able to mark pages with characteristics and notes?
- how can i show WordPress custom field data to my short code?
- add different custom fields value to post class if permalink or index
- author.php not showing content if Author has no Posts
- Create Shortcode shows only posts with custom_field meta
- Custom Fields Not Working In Footer
- Login_form add to top of form rather then bottom
- Advanced Custom Fields from Category – IF statement
- Get a different meta value with ajax when different elements are clicked
- Delete custom fields on post publish?
- Permalink structure depending on custom field
- How to add custom field option with menu?
- How to add custom_fields value in JSON API using create_post
- Using Hooks. Thematic
- WP Post Meta Box Field Not Showing Updated Field
- WP_Query based on multiple metadata comparisons
- Parse Shortcodes in Theme’s Custom Field?
- Alter SQL query to return posts with unique custom field value, no duplicate values
- custom field output after the_content
- Update field name without losing the value
- Post count by meta_key meta_value [closed]
- How do delete a meta key?
- Is there a way to read JSON data inside Custom Fields without editing PHP? [closed]
- Modal pop-up HTML code works on other sites or HTML viewers but not in the custom HTML block within a wordpress page?
- Automatically changing a posts status to draft based on magic fields [closed]
- Custom post type needs to capability to create and edit by some specific user role