WordPress.org

Ready to get started?Download WordPress

Forums

Job Manager
FR: give post types labels and names (7 posts)

  1. Jason Judge
    Member
    Posted 3 years ago #

    This is a feature request to give the post types that this plugin creates proper labels and names. All the post types are called "Post" and all the taxonomy lists are called "Category", both of which are just the WordPress defaults.

    The purpose of the request is just to enable site managers to organise the data on their WP site, i.e. being able to see what plugin data belongs to.

    The change would be in jobman_page_taxonomy_setup() of functions.php The calls to register_post_type() would need to include 'labels' element, with sub-elements 'name' and 'singular_name'. Similarly for calls to register_taxonomy().

    See http://codex.wordpress.org/Function_Reference/register_post_type for more details.

    This will not have an operational or functional effect on this plugin, but would help site administrators of complex sites and developers immensely.

    -- Jason

    http://wordpress.org/extend/plugins/job-manager/

  2. Jason Judge
    Member
    Posted 3 years ago #

    To make it easy, here is my version of the function:

    function jobman_page_taxonomy_setup() {
    	// Create our new post types
    	register_post_type( 'jobman_job', array( 'exclude_from_search' => false, 'labels' => array('name' => 'Jobman Job') ) );
    	register_post_type( 'jobman_joblist', array( 'exclude_from_search' => true, 'labels' => array('name' => 'Jobman Job List') ) );
    	register_post_type( 'jobman_app_form', array( 'exclude_from_search' => true, 'labels' => array('name' => 'Jobman App Form') ) );
    	register_post_type( 'jobman_app', array( 'exclude_from_search' => true, 'labels' => array('name' => 'Jobman App') ) );
    	register_post_type( 'jobman_register', array( 'exclude_from_search' => true, 'labels' => array('name' => 'Jobman Register') ) );
    	register_post_type( 'jobman_email', array( 'exclude_from_search' => true, 'labels' => array('name' => 'Jobman Email') ) );
    	register_post_type( 'jobman_interview', array( 'exclude_from_search' => true, 'labels' => array('name' => 'Jobman Interview') ) );
    
    	// Create our new taxonomy thing
    	$options = get_option( 'jobman_options' );
    
    	$root = get_page( $options['main_page'] );
    	$url = get_page_uri( $root->ID );
    
    	if( substr( $url, 0, 1 ) != '/' )
    		$url = "/$url";
    
    	register_taxonomy( 'jobman_category', array( 'jobman_job', 'jobman_app' ), array( 'hierarchical' => false, 'label' => __( 'Category', 'series' ), 'query_var' => 'jcat', 'rewrite' => array( 'slug' => $url ), 'labels' => array('name' => 'Jobman Category') ) );
    }

    When managing data through other plugins such as "more types", it just makes the admin screens there that much easier to follow.

  3. lauraupcott
    Member
    Posted 3 years ago #

    judgej thanks for sharing your code!

    I want to add your post types to my site. If I understand correctly, I just have to paste your code at the end of my functions.php file.

    Is that right?

  4. Jason Judge
    Member
    Posted 3 years ago #

    There should already be a function called "jobman_page_taxonomy_setup" which starts and ends like this:

    function jobman_page_taxonomy_setup() {
    ...
    }

    This is in functions.php of the plugin. The code I pasted should replace that section completely. If you prefer to paste it at the end of the functions.php file, make sure to rename the original function name, e.g.:

    function jobman_page_taxonomy_setup_ORIGINAL_DISABLED() {
    ...
    }

    That ought to work (it does for me). Luckily the plugin does not need to be reinstalled or anything - just paste in the code and the custom post types show up with proper names when viewed from other modules such as "more types" or "wp custom post types".

    Note also that this is likely to be over-written each time the plugin is updated, so I'm hoping it will make it into the core plugin so we no longer have to keep pasting it.

    -- Jason

  5. Jason Judge
    Member
    Posted 3 years ago #

    This is what the admin page of the "more types" plugin shows with the above function pasted in:

    screen shot

    Before that every line just said Post...Post...Post... and I had no idea which one to edit in order to extend them.

  6. lauraupcott
    Member
    Posted 3 years ago #

    Thanks for clarifying. I found the "jobman_page_taxonomy_setup" section of the "job-manager/functions.php" file. So now it's just a matter of cut and paste.

    I think there's a good chance that Gary Pendergast will notice your post and add your custom post types to the next install. But we can always update the file again after the next upgrade if necessary.

    -- Laura

  7. Jason Judge
    Member
    Posted 3 years ago #

    I certainly hope so. It's a lovely plugin. It is a shear pleasure walking through the code that oozes quality and good practice. There are few plugins for WP that I can say that about ;-)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic