Trivia Challenge Block
WordPress Gutenberg block for interactive trivia quizzes
by Jon Imms · github.com/jonimmswordpressdev/trivia-challenge-block · website
★ 0stars
0forks
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/jonimmswordpressdev/trivia-challenge-block/archive/refs/heads/main.zipA custom WordPress Gutenberg block that adds an interactive general knowledge trivia quiz to your website.
Features
- 🎯 6 Quiz Categories: Mixed, Science & Nature, History, Geography, Entertainment, and Sports
- 📚 150+ Questions: Curated trivia questions across all categories
- 🎨 Customizable Colors: Change primary and secondary colors in the block settings
- 📊 Score Tracking: Real-time scoring with visual feedback
- 📱 Fully Responsive: Works perfectly on desktop, tablet, and mobile devices
- ⚡ Fast & Lightweight: Built with React and optimized for performance
- ♿ Accessible: Keyboard navigation and screen reader friendly
Installation
Method 1: Upload via WordPress Admin
- Download the plugin folder
- Zip the
trivia-challenge-blockfolder - In WordPress admin, go to Plugins > Add New > Upload Plugin
- Choose the zip file and click Install Now
- Activate the plugin
Method 2: Manual Installation
- Upload the
trivia-challenge-blockfolder to/wp-content/plugins/ - Activate the plugin through the Plugins menu in WordPress
Method 3: Development Setup
If you want to modify the block:
cd wp-content/plugins/trivia-challenge-block
npm install
npm run start
For production build:
npm run build
Usage
- Create or edit a page/post in WordPress
- Click the + button to add a new block
- Search for "Trivia Challenge" or find it in the Trivia Challenge category
- Insert the block into your page
- (Optional) Customize the colors in the block settings sidebar
- Publish your page
Customization
Changing Colors
You can customize the quiz colors directly in the block editor:
- Select the Trivia Challenge block
- Open the Block Settings sidebar (right panel)
- Expand the Color Settings panel
- Choose your Primary Color and Secondary Color
Adding More Questions
To add more questions, edit the src/frontend.js file and add questions to the triviaQuestions object:
const triviaQuestions = {
mixed: [
{
q: "Your question here?",
a: ["Correct Answer", "Wrong 1", "Wrong 2", "Wrong 3"],
correct: 0
},
// Add more questions...
],
// Other categories...
};
After adding questions, rebuild the plugin:
npm run build
Creating New Categories
- Add a new category to the
triviaQuestionsobject insrc/frontend.js - Add the category option in
src/frontend.jsin the SetupScreen component - Rebuild the plugin
File Structure
trivia-challenge-block/
├── build/ # Compiled files (generated)
├── src/
│ ├── index.js # Block registration & editor
│ ├── frontend.js # React frontend component
│ ├── editor.scss # Editor styles
│ └── style.scss # Frontend styles
├── package.json # Dependencies
├── trivia-challenge-block.php # Main plugin file
└── README.md # This file
Requirements
- WordPress 6.0 or higher
- PHP 7.4 or higher
- Modern browser with JavaScript enabled
Development
Build Commands
npm run start- Start development mode with hot reloadnpm run build- Build for productionnpm run format- Format codenpm run lint:js- Lint JavaScript filesnpm run lint:css- Lint CSS/SCSS files
Technologies Used
- React
- WordPress Block Editor (Gutenberg)
- SASS/SCSS
- @wordpress/scripts
Browser Support
- Chrome (latest)
- Firefox (latest)
- Safari (latest)
- Edge (latest)
License
GPL-2.0+
Author
Jon Imms - jonimms.com
Support
For issues or questions, please visit [your support page or GitHub issues]
Changelog
1.0.0
- Initial release
- 6 quiz categories
- 150+ questions
- Customizable colors
- Fully responsive design
- Score tracking