Create a Custom Post Type:
// Add this code to your theme's functions.php file or a custom plugin
function create_collaborator_post_type() {
$args = array(
'public' => true,
'label' => 'Collaborators',
'supports' => array('title', 'editor', 'thumbnail'),
// Add any additional fields you need for collaborators
// such as 'region', 'profession', etc.
);
register_post_type('collaborator', $args);
}
add_action('init', 'create_collaborator_post_type');
Create Page Templates:
Create separate template files for each region and profession. For example, create page-region.php and page-profession.php in your theme folder.
Add Form to Each Template:
In each template file, add a form to collect the collaborator information:
<!-- Add this code to page-region.php -->
<form method="post">
<label for="name">Name:</label>
<input type="text" name="name" id="name" required>
<!-- Add more fields for region-specific information -->
<input type="submit" value="Submit">
</form>
<!-- Add this code to page-profession.php -->
<form method="post">
<label for="name">Name:</label>
<input type="text" name="name" id="name" required>
<!-- Add more fields for profession-specific information -->
<input type="submit" value="Submit">
</form>
Process Form Submission:
Handle the form submission in each template file and create a new post for the collaborator:
// Add this code to page-region.php and page-profession.php after the form HTML
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = $_POST['name'];
// Get other form fields
$post_data = array(
'post_title' => $name,
'post_type' => 'collaborator',
// Set other post meta values based on form input
);
$post_id = wp_insert_post($post_data);
if ($post_id) {
// Display a success message or redirect to a thank-you page
} else {
// Display an error message
}
}
Display Personal Cards:
Query and display the personal cards in each template file:
// Add this code to page-region.php and page-profession.php after the form processing code
$args = array(
'post_type' => 'collaborator',
// Add additional arguments to filter by region or profession
);
$query = new WP_Query($args);
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
// Display the collaborator information
the_title('<h2>', '</h2>');
the_content();
// Display additional fields
// Add appropriate HTML and styling for the personal cards
}
wp_reset_postdata();
} else {
// Display a message when no collaborators are found
}
Remember to customize the code according to your specific requirements, such as adding additional fields, styling, and customizing the loop to display the collaborator details as desired.
Please note that this code serves as a starting point and may require further adjustments based on your specific needs and theme structure.