首页 > 解决方案 > 在弹出窗口中显示 WP Job Manager 自定义字段

问题描述

我正在使用 WP Job Manager 插件来允许在我的网站上提交工作申请。按照插件开发人员的官方文档,我使用此功能创建了自定义电话字段:

// Add field to admin
add_filter( 'resume_manager_resume_fields', 'wpjms_admin_resume_form_fields' 
);
function wpjms_admin_resume_form_fields( $fields ) {

$fields['_candidate_color'] = array(
    'label'         => __( 'Phone', 'job_manager' ),
    'type'          => 'text',
    'placeholder'   => __( 'Enter your phone', 'job_manager' ),
    'description'   => '',
    'priority' => 1
);

return $fields;

}

// Add field to frontend
add_filter( 'submit_resume_form_fields', 'wpjms_frontend_resume_form_fields' 
);
function wpjms_frontend_resume_form_fields( $fields ) {

$fields['resume_fields']['phone'] = array(
    'label' => __( 'Phone', 'job_manager' ),
    'type' => 'text',
    'required' => true,
    'placeholder' => '',
    'priority' => 1
);

return $fields;

}

// Add a line to the notifcation email with custom field
add_filter( 'apply_with_resume_email_message', 
'wpjms_color_field_email_message', 10, 2 );
function wpjms_color_field_email_message( $message, $resume_id ) {
$message[] = "\n" . "Phone: " . get_post_meta( $resume_id, '_phone', true );  
return $message;
}

并且我尝试在此处显示 ex 的绿色联系人弹出按钮,但似乎使用一些开发人员建议的此代码没有显示任何内容:

<?php echo get_post_meta( $post->ID, '_phone', true ); ?>

我尝试使用相同的代码显示到绿色弹出窗口中,但它不起作用。电话已插入该应用程序的管理区域,并在检查时显示。这是弹出区域的外观:

<div class="resume_contact">

    <a href="#resume-dialog" class="small-dialog popup-with-zoom-anim button"><i class="fa fa-envelope"></i> <?php esc_html_e( 'Contact', 'workscout' ); ?></a>
    <div id="resume-dialog" class="small-dialog zoom-anim-dialog mfp-hide apply-popup">
        <div class="small-dialog-headline">
            <h2><?php esc_html_e('Send Message','workscout'); ?></h2>
        </div>
        <div class="small-dialog-content">
            <!--<?php do_action( 'resume_manager_contact_details' ); ?>--> // Need to show phone content here !
        </div>
    </div>
</div>

啊啊帮助在这里如何显示?

标签: phpwordpressfunction

解决方案


固定我自己:)

问题在这部分:

add_filter( 'resume_manager_resume_fields', 'wpjms_admin_resume_form_fields' 
);
function wpjms_admin_resume_form_fields( $fields ) {

$fields['_candidate_color'] = array(  // Here i didnt renamed field to _phone  lol :D
'label'         => __( 'Phone', 'job_manager' ),
'type'          => 'text',
'placeholder'   => __( 'Enter your phone', 'job_manager' ),
'description'   => '',
'priority' => 1
);

return $fields;

}

现在工作正常。感谢任何人的帮助。


推荐阅读