A fun quiz game built with React for WordPress frontend. This plugin allows you to embed an interactive quiz on any WordPress page or post using a simple shortcode.
- Interactive quiz with multiple-choice questions
- Score tracking and display
- High scores leaderboard
- Responsive design that works on all devices
- WordPress REST API integration for data storage
- Built with modern React and WordPress scripts
- Download the plugin zip file or clone the repository to your WordPress plugins directory
- Navigate to your WordPress plugins directory:
wp-content/plugins/ - If you downloaded the zip, extract it to the plugins directory
- Activate the plugin through the WordPress admin interface
Add the quiz to any page or post using the shortcode:
[react_quiz]
The quiz questions are defined in the src/index.js file. You can modify the questions array to add your own questions:
const questions = [
{
question: 'Your question here?',
options: ['Option 1', 'Option 2', 'Option 3', 'Option 4'],
correct: 2 // Index of the correct answer (0-based)
},
// Add more questions...
];wp-react-frontend/
├── build/ # Compiled files (generated)
├── src/ # Source files
│ ├── index.js # Main React application
│ └── styles.css # Styles
├── wp-react-frontend.php # Main plugin file
├── package.json # npm dependencies and scripts
└── README.md # This file
- Clone the repository to your WordPress plugins directory
git clone https://github.com/ikamal7/wp-react-frontend.git wp-content/plugins/wp-react-frontend- Navigate to the plugin directory
cd wp-content/plugins/wp-react-frontend- Install dependencies
npm install- Start the development server
npm start- Build for production
npm run buildnpm start- Starts the development server with hot reloadingnpm run build- Builds the app for productionnpm run format- Formats code using WordPress coding standardsnpm run lint:js- Lints JavaScript files
The plugin registers the following REST API endpoints:
POST /wp-json/wp-react-frontend/v1/save-score- Save a player's scoreGET /wp-json/wp-react-frontend/v1/high-scores- Get the top 10 high scores
The plugin creates a custom database table {prefix}_quiz_scores to store player scores with the following structure:
id- Auto-incremented IDplayer_name- Name of the playerscore- Player's scorecreated_at- Timestamp when the score was recorded
For support, feature requests, or bug reports, please open an issue on GitHub.
GPL v2 or later
Developed by Kamal Hosen.