Solving onPopState on Chrome and Safari

In an older post we talked about getting the previous page URL with a backspace event. However, for some people using older versions of Chrome or Safari, this would cause the page to constantly refresh due to Chrome or Safari’s browser emitting a onPopState event on page load. Here’s how to solve the issue for onPopState on Chrome and Safari.

View Article

Getting the Previous Page URL with Backspace Event

It used to be pretty troublesome to detect a backspace event in your standard browsers. With the release of the HTML5 History API, stateful websites are now made possible to allow your script to detect the previous page’s URL when the user does a backspace event in Javascript.

For this tutorial, we will be using window.onPopState to detect the back / forward button navigation for the browser, and location.pathname to get the path.

View Article

Implementing a WordPress Post Title Link

Adding a WordPress post title is quite simple, but if you’re just starting into developing your own WordPress based website, their documentation might be a bit confusing as it is introduced part by part to you. This post will serve to bridge the gap between the functions you need to use to add a wordpress post title link in your site so you are able to direct your users into the single post on your desired page.

View Article

Creating Custom WordPress Menus for your Website

If you’re using WordPress as a CMS, you’ll see that you only have one menu to work with and it only appears on the header navigation area. However, you will eventually want to know how to create a custom menu to add into certain sections of your site, in which this following tutorial will show you how.

WordPress provides a step-by-step approach to creating your custom WordPress menus. You will have to register your custom menus first, then link and add your menus onto the frontend. There are also two ways of registering your custom menu with register_nav_menu and register_nav_menus. I like to use register_nav_menus because of it’s convenience of adding multiple menus via an array, so this will cover only just that.

View Article

Wrapping <li> tags in <a> tags

For those obsessed with allowing the browser and any potential web crawlers to correctly understand what your code means, this is pretty important — which is semantically correct?

View Article

Odd and Even Elements with CSS Selectors

Wondering how do you select odd and even elements with CSS selectors? It’s pretty easy, given that there are a few different ways that you could utilize CSS pseudo class selectors to selectively style your code.

If you’re using nth-child() or nth-of-type(), there are 2 ways to select the odd or even elements in a parent element.

View Article