Geolocation API with HTML5

Geolocation API and a browser supporting HTML5 location feature, may help you to know geolocation of a visitor (not so much accurate, cause it doesn’t use GPS to get location).
How? Let’s take a look to a simple code:

function GeoHtml5()
	if (navigator.geolocation)
        alert("geo not supported");
function onGetPosition(geolocation)
    var latitude = geolocation.coords.latitude;
    var longitude = geolocation.coords.longitude;
    alert("Your lat: " + latitude + "\nYour long: " +  longitude);
function onErrorPosition()
    alert("Error on get position");

First function, detects if browser supports this feature. Second one is triggered when getting location is OK, second one when it’s not. I’m not going to explain inline code, because it’s very intuitive and simple.

Here is the code running.

If W3C and browser “companies” improves it, it could reduce a little bit more differences with mobile’s web-apps and native apps.

For more information, visit W3c’s Geolocation API site.

Read More

How and why to create a “child theme” in WordPress

Child themes are those which inherit styles and functionalities from another parent theme.

Why use child themes?
One of multiple utilities reside in change ,for example, only the styles/appearance without creating a new theme (because a child theme, just require a style.css file). For example, if you want to change colorset of your current theme and you edit their style.css, everything will be ok… until you update your theme and you will lose all your changes.

How to do that?
Is simple as just create one folder in your /wp-content/themes/ , just as another wp theme. Then, just copy (eg.) parent theme style.css, and add this at the beggining:

Theme Name:     Responsive personalitzat
Description:    Child theme for responsive theme
Author:         Albert Casadessús
Author URI:
Template:       responsive
Version:        0.1.0

Where Template must be the name of the parent theme folder (case sensitive!). Above there’s style.css of my child theme to change a bit the responsive theme I use.

So in this example, my folder struct will be:
(and if you want to modify another files, just put in the folder and think about the header above)
/wp-content/themes/responsive/(with all the files of the theme)

Read More