Featured Professor Block Type
Wordpress plugin build with php and react
by Gabriel · github.com/gabrielgpacheco/wp-plugin-featured-professor
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/gabrielgpacheco/wp-plugin-featured-professor/archive/refs/heads/main.zipA WordPress plugin that creates a custom Gutenberg block for displaying featured professors with related content.
Description
The Featured Professor plugin adds a custom Gutenberg block that allows you to showcase professors from your WordPress site. The block displays professor information including their photo, biography excerpt, related programs they teach, and a link to their full profile. Additionally, the plugin automatically adds a list of posts that mention the professor at the bottom of professor single pages.
Features
- Custom Gutenberg Block: Add a "Professor Callout" block to any post or page
- Professor Selection: Choose from existing professor posts in a dropdown selector
- Responsive Design: Modern, mobile-friendly layout with CSS flexbox
- Dynamic Content: Automatically fetches professor data including photo, bio, and related programs
- Related Posts: Automatically displays posts that reference the professor on professor single pages
- Internationalization Ready: Includes translation files and text domain setup
- REST API Integration: Uses WordPress REST API to fetch professor HTML dynamically
Requirements
- WordPress 5.0+ (Gutenberg editor)
- PHP 7.0+
- Node.js and npm (for development)
Installation
Method 1: Manual Installation
- Download the plugin zip file
- Upload to your WordPress site via FTP to
/wp-content/plugins/ - Extract the plugin files
- Activate the plugin from the WordPress admin panel
Method 2: WordPress Admin
- Go to Plugins → Add New
- Click "Upload Plugin"
- Choose the plugin zip file
- Click "Install Now"
- Activate the plugin
Usage
Adding a Featured Professor Block
- Create or edit a post/page
- Click the "+" button to add a new block
- Search for "Professor Callout" or find it in the "Common Blocks" category
- Select a professor from the dropdown menu
- The block will display the professor's information automatically
Setting Up Professors
- Ensure you have a custom post type "professor" registered on your site
- Create professor posts with:
- Featured image (used as portrait)
- Content (biography)
- Custom field "related_programs" (ACF relationship field) linking to program posts
Related Posts Feature
The plugin automatically adds a "Related Posts" section to professor single pages that lists all posts where the professor has been featured. This works by checking for posts with the featuredprofessor meta field matching the professor's ID.
Development
Project Structure
featured-professor/
├── featured-professor.php # Main plugin file
├── package.json # Node.js dependencies
├── src/
│ ├── index.js # React block editor component
│ └── index.scss # Block styles
├── inc/
│ ├── generateProfessorHTML.php # PHP template for professor display
│ └── relatedPostsHTML.php # PHP template for related posts
├── build/ # Compiled assets
│ ├── index.js
│ ├── index.css
│ └── index.asset.php
└── languages/ # Translation files
Building from Source
- Clone the repository
- Run
npm installto install dependencies - Run
npm run startfor development mode (watch for changes) - Run
npm run buildto compile production assets
Dependencies
@wordpress/scripts(v26.14.0) - WordPress development tools- React - JavaScript library for building user interfaces
- WordPress REST API - For fetching professor data
Customization
Styling
The plugin includes SCSS files that can be modified to change the appearance. The main styles are in src/index.scss and include:
- Professor callout container styles
- Responsive layout for different screen sizes
- Typography and spacing
Translation
The plugin is translation-ready with text domain featured-professor. Translation files are located in the languages/ directory. To add translations:
- Use the
.potfile as a template - Create
.pofiles for your language - Compile to
.mofiles for production use
API Endpoints
The plugin registers a REST API endpoint:
GET /wp-json/featuredProfessor/v1/getHTML?profId={id}Returns HTML for the specified professor ID
Hooks and Filters
Actions
init- Registers block type and meta fieldsrest_api_init- Registers REST API endpointthe_content- Adds related posts to professor single pages
Filters
the_content- Filters professor single page content to add related posts
Frequently Asked Questions
How do I create professor posts?
Professor posts use a custom post type "professor". You'll need to register this post type separately or use a plugin that creates it.
Can I use this with any post type?
The block is specifically designed for the "professor" post type. To use with other post types, you would need to modify the code.
How are related programs displayed?
The plugin looks for an Advanced Custom Fields (ACF) relationship field called "related_programs" on professor posts. Each related program title is listed.
Can I customize the HTML output?
Yes, modify inc/generateProfessorHTML.php to change the HTML structure of the professor callout.
Changelog
1.0.0
- Initial release
- Featured Professor Gutenberg block
- Professor selection dropdown
- Responsive design
- Related posts functionality
- Internationalization support
License
This plugin is licensed under the GPL v2 or later. See the LICENSE file for details.
Credits
Author: Gabriel
Author URI: https://gabrielpacheco.com.br
Support
For support, feature requests, or bug reports, please create an issue on the GitHub repository.