Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi there, I noticed you commented on my thread that I self resolved and a mod closed it before you could get your answer.

    If you’re still having problems, start a new thread and I’ll try and help you.

    Thread Starter georgew0304

    (@georgew0304)

    Right, the first field you need to edit is
    includes/forms/class-wp-job-manager-form-submit-job.php

    Around line 100 you need to add an array similar to the following (Use the other arrays on the file to give you an idea)

    'application_deadline' => array(
    					'label'       => __( 'Application Deadline', 'job_manager' ),
    					'type'        => 'text',
    					'required'    => true,
    					'placeholder' => '',
    					'priority'    => 7
    				),

    Make sure you have a different priority to the others.

    Then around line 435 you need to add a line to put the form input into the database.

    Add something like this:
    update_post_meta( self::$job_id, '_application_deadline', $values['job']['application_deadline'] );

    That should handle the adding the entry to the database side of things.

    Now to add the function to get the element from the database.

    Open up the file wp-job-manager-template.php

    You can add this function to the bottom of the file:

    /**
     * Display or retrieve the current application deadline with optional content.
     *
     * @access public
     * @param mixed $id (default: null)
     * @return void
     */
    function the_application_deadline( $before = '', $after = '', $echo = true, $post = null ) {
    	$application_deadline = get_the_application_deadline( $post );
    
    	if ( strlen( $application_deadline ) == 0 )
    		return;
    
    	$application_deadline = esc_attr( strip_tags( $application_deadline ) );
    
    	if ( $echo )
    		echo $application_deadline;
    	else
    		return $application_deadline;
    }
    
    /**
     * get_the_application_deadline function.
     *
     * @access public
     * @param int $post (default: 0)
     * @return void
     */
    function get_the_application_deadline( $post = null ) {
    	$post = get_post( $post );
    	if ( $post->post_type !== 'job_listing' )
    		return;
    
    	$application_deadline = $post->_application_deadline;
    
    	if ( strlen( $application_deadline ) == 0 )
    		return;
    
    	if ( strpos( $application_deadline, '' ) === 0 )
    		$application_deadline = substr( $application_deadline, 1 );
    
    	return apply_filters( 'the_application_deadline', $application_deadline, $post );
    }

    Now you should just be able to add <?php the_application_deadline(); ?> to bring up the application deadline.

    Just an advisory, I’m not a professional developer. You should look over my code, as I’ve mainly looked over current code and replicated it with minor changes.

    Thread Starter georgew0304

    (@georgew0304)

    Ah, I have fixed it. It’s a case of adding the function to wp-job-manager-template.php.

    Thread Starter georgew0304

    (@georgew0304)

    Alright, I’ve managed to get it to show up in the database with a meta key and meta value. I’m working on getting it to show up on the job listing now.

Viewing 4 replies - 1 through 4 (of 4 total)