I'm currently trying to add a static page to my custom post type. The reason for this is:
-I'd like my client to be able to change a feature image to my archive-our_classes.php, as well as use a call to action block that I've created with custom fields.
I've looked at this answer here, and can't seem to get my code to work - please help! (Note: I did not change their notes from Projects to "our_classes")
Add Static Page to Reading Settings for Custom Post Type
add_action( 'admin_init', function () {
$id = 'our_classes';
// add_settings_field( $id, $title, $callback, $page, $section = 'default', $args = array() )
add_settings_field( $id, 'Our Classes Page:', 'settings_field_our_classes', 'reading', 'default', array(
'label_for' => 'field-' . $id, // A unique ID for the field. enter code hereOptional.
'class' => 'row-' . $id, // A unique class for the TR. Optional.
) );
} );
/**
* Renders the custom "Projects page" field.
*
* @param array $args
*/
function settings_field_our_classes( $args ) {
$id = 'our_classes';
wp_dropdown_pages( array(
'name' => $id,
'show_option_none' => '— Select —',
'option_none_value' => '0',
'selected' => get_option( $id ),
) );
}
/**
* Adds page_for_projects to the white-listed options, which are automatically
* updated by WordPress.
*
* @param array $options
*/
add_filter( 'whitelist_options', function ( $options ) {
$options['reading'][] = 'our_classes';
return $options;
} );
I'd love assistance on how to get this to work! Thanks in advance!