How to edit the hosts file in MacOS, Windows and Linux

The hosts file is a text file that maps hostnames to IP addresses. Upon typing a url address on the browser, the system is checking if there is a relevant entry on the hosts file and gets the corresponding IP address, else it resolves the IP via the active connection’s DNS servers. The hosts file can also be edited to block certain hostnames (like ad-serving/malicious hosts), or used for web development purposes, i.e. to redirect domains to local addresses. Editing the hosts file in MacOS Open the Start typing Terminal on the Spotlight, or by going into Applications -> Utilities ->...

WordPress logo

Retrieve and get WordPress post ID outside the loop

Outside the Loop or out of the context of the post, such as in the header or the footer and even sidebar area in WordPress templates, the_ID() cannot be used as a function. Instead, $post->ID is used to return the post ID. $post is a global object that holds various information about the posts displayed on the page.