Posts

Showing posts from May, 2021

WordPress Modifying A Child Theme & Using The OpenWeatherMap API

Image
The modification of a WordPress child theme can be accomplished in multiple stages. For my child theme modification users can search the name of a city and are provided some current weather data from openweathermap. To accomplish this I used TypeScript to make my requests and perform DOM manipulation. Child Theme Creation & OpenWeatherMap API To create a child them, navigate to the directory where WordPress themes are stored. Create a new directory that uses a similar name to the parent them you wish to extend, however append the text "-child" to the end. This text does not do anything, however this is considered best practice (WordPress, n.d.). This directory requires several files in order to be operational. Firstly, a CSS file that contains a description of the theme is required. This should be named style.css and contain text similar to the following extract. The child theme will now be available for activation thro...

Deleting A WordPress Blog Post Using The WordPress REST API

Image
The NextJs application allows users to delete blog posts using the WordPress REST API by sending HTTP DELETE requests to the endpoint specified by the WordPress Developers website. Users are required to login before the delete button appears for a blog post. Upon clicking the delete button the user is provided visual feedback that the post has been deleted in the form of a red background for the post listing. The following screenshot shows the network tab found within the Chrome developer tools. The highlighted network request is for the deletion of a blog post with ID 168. The documentation for sending CRUD operations to a WordPress servers REST API can be found on the WordPress Developer website (WordPress, n.d.). The following code extract provides detail on how the request is sent, using the fetchJSON function. Much of the contents of this functional component have been omitted due to its length, with the most important part of the mechanism being shown below. Deleting posts using ...