WordPress get domain

There are times when you only want to use your domain to show in your footer, for example, or use it as a dynamic logo. In order to obtain the domain you need your site url and then retrieve the protocols here. You can do this in the following ways: The reason I use site_url() […]

Difference between site url and home url

WordPress has 2 inbuilt functionalities to get the site url: The site_url() will always be the location where you can reach the site by tacking on /wp-adminon the end, while home_url() would not reliably be this location. You can also get this same field by using get_bloginfo( ‘wpurl’ ). The home_url() would be where you have set your homepage by setting General […]

Get featured image url

To get the featured image URL from a WordPress post you first have to be clear which URL you should have. There are multiple sizes of the image available. The default size is “post-thumbnail”, but you can also get the “small”, “medium” and “large” sizes, or custom sizes added by add_image_size(). Use the following function […]

Programmatically 301 redirect by url

There are times when you need to remove posts from your website and want to redirect them to another post. You can simply do this by checking the old post’s ID and set a 301 redirect to another post and keep the old post in your database. This basically gives the right result, but with larger projects […]