It is a react application that uses a local wordpress website as the headless cms. Registered users can login into the website and can then post comments. All users irrespective of login can search the posts based on some term from the home page. Users can also see posts segregated by categories using the navbar which is also fetched from the wordpress cms. Also each user can read the approved comments on the posts. It also has 2 plugins that hook into the rest api and create custom end points for us to fetch data.
Wordpress admin page for url format
- Download the github repo.
- Create a local wordpress installation using any tool of your choice. In the project LocalWp by flywheel is used. (https://localwp.com/).
- Copy the content of Wordpress Code/Plugins/ into the plugins directory of your local install to create the functionality of custom end points in the api.
- Go to the wordpress admin panel and activated the 2 new plugins.
- Change the REACT_APP_WP_SITE_URL variable's value with your local wordpress installation's url.
- Create some posts in your wordpress installation with some separate categories.
- Create a menu in wordpress admin panel with the name menu.
- Add custom links in the menu with the url in format /posts/:your_category_here:. For example for a category DC the url will look like /posts/dc.
- Install the JWT Authentication for WP-API plugin from admin dashboard. This will be used for authentication using JWT.
- Open the .htaccess file in your public directory of local wordpress installation and add the following code to it:
RewriteEngine on
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
- Open the .wp-config file in your public directory of local wordpress installation and add the following code to it:
define('JWT_AUTH_SECRET_KEY', 'your-top-secret-key_here');
- In the root folder of you application run npm -i to install the dependencies.
- Run the local wordpress installation.
- Run the application using npm start.