1

I have a Custom Post Type "Vacancies". I have successfully created a Sub Menu Item in the admin menu "Background". I would like to show a file upload form to allow the admin the ability to upload a background image that will then be used for the archive-vacancies.php template. here is what I have so far:

enter image description here

/** Step 1. */
function my_plugin_menu() {
    // add_options_page( 'My Plugin Options', 'My Plugin', 'manage_options', 'my-unique-identifier', 'my_plugin_options' );
    add_submenu_page('edit.php?post_type=vacancies', 'Background Image', 'Background', 'manage_options', 'my-unique-identifier', 'my_plugin_options');
}

/** Step 2. */
add_action( 'admin_menu', 'my_plugin_menu' );

/** Step 3. */
function my_plugin_options() {
    if ( !current_user_can( 'manage_options' ) )  {
        wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
    }

    wp_enqueue_media(); 

    ?>

    <h3>Background Image</h3>

    <table class="form-table">
        <tr>
            <th>
                <label for="coverimage">Background Image</label>
            </th>

            <td>
                <img class="user-cover-image" id="user-cover-image-preview" src="<?php //echo esc_attr( get_the_author_meta( 'coverimage', $user->ID ) ); ?>" style="width:150px;"><br />

                <input type="text" name="coverimage" id="coverimage" value="" class="regular-text" />
                <input type='button' class="user-cover-image button-primary" value="Upload Image" id="uploadimage"/><br />

                <span class="description">Please upload a background image for the Vancancies Archive page.</span>
            </td>
        </tr>

    </table>
<?php }
  • What is the question? – jdm2112 May 22 '18 at 15:28
  • I am needing a way to upload an image and it be associated with the custom post type. I think I might have just found a solution. A plugin to add images to Categories or Tags. – Jason May 22 '18 at 15:30
0

My issue is resolved with this plugin "Categories Images"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.