DEV Community

hub
hub

Posted on

Add-on for the wpjobmanager that adds Company Profiles functionality

i want to write an Add-on for the wpjobmanager that adds Company Profiles functionality - with the following options: It Outputs a list of all companies that have submitted jobs with links to their listings and profile.

here a general guideline for creating an add-on for WP Job Manager that adds Company Profiles functionality and outputs a list of all
companies that have submitted jobs with links to their listings and profiles. Here are the steps you can follow:

we create a new plugin for WP Job Manager by creating a new folder in the plugins directory with a unique name.

we create a new file in the new folder and name it after our plugin. For example, if our plugin is called "Company Profiles," we name the file "company-profiles.php."

In the new PHP file, we use the add_action() function to create a new page for our plugin in the WP Job Manager menu. For example:

add_action( 'jm_admin_menu', 'company_profiles_menu' );
function company_profiles_menu() {
add_submenu_page(
'edit.php?post_type=job_listing',
__( 'Company Profiles', 'company-profiles' ),
__( 'Company Profiles', 'company-profiles' ),
'manage_options',
'company-profiles',
'company_profiles_page'
);
}

  1. Define the function company_profiles_page() to display the contents of our new page. This could include a list of all companies that have submitted jobs, along with links to their listings and profiles. For example:

`function company_profiles_page() {
$companies = get_posts( array(
'post_type' => 'company',
'orderby' => 'title',
'order' => 'ASC',
'numberposts' => -1
) );

if ( $companies ) {
    echo '<ul>';
    foreach ( $companies as $company ) {
        $company_link = get_permalink( $company->ID );
        $company_name = get_the_title( $company->ID );
        $job_listings = get_job_listings_by_company( $company->ID );
        if ( $job_listings ) {
            $job_count = count( $job_listings );
            $job_listings_link = get_post_type_archive_link( 'job_listing' ) . '?company=' . $company->ID;
            echo '<li><a href="' . $company_link . '">' . $company_name . '</a> (' . $job_count . ' job listings) - <a href="' . $job_listings_link . '">View job listings</a></li>';
        } else {
            echo '<li><a href="' . $company_link . '">' . $company_name . '</a> (no job listings)</li>';
        }
    }
    echo '</ul>';
} else {
    echo '<p>No companies found.</p>';
}
Enter fullscreen mode Exit fullscreen mode

}`

5: Create a new custom post type for company profiles. For example:

`add_action( 'init', 'create_company_post_type' );

function create_company_post_type() {
$labels = array(
'name' => x( 'Companies', 'post type general name', 'company-profiles' ),
'singular_name' => _x( 'Company', 'post type singular name', 'company-profiles' ),
'menu_name' => _x( 'Companies', 'admin menu', 'company-profiles' ),
'name_admin_bar' => _x( 'Company', 'add new on admin bar', 'company-profiles' ),
'add_new' => _x( 'Add New', 'company', 'company-profiles' ),
'add_new_item' => _
( 'Add New Company', 'company-profiles' ),
'new_item' => __( 'New Company',)`

Here we go...

Top comments (0)