I would like to add a dropdown of pages for each of my custom post types in the reading settings just under dropdown for posts.
The dropdown of pages for my custom post type is used to configure the archive url by associating to existing page.
As wordpress suggest in https://codex.wordpress.org/Settings_API, I would add a new field like this:
function eg_settings_api_init() {
add_settings_section(
'eg_setting_section',
'Example settings section in reading',
'eg_setting_section_callback_function',
'reading'
);
add_settings_field(
'eg_setting_name',
'Example setting Name',
'eg_setting_callback_function',
'reading',
'eg_setting_section'
);
register_setting( 'reading', 'eg_setting_name' );
}
add_action( 'admin_init', 'eg_settings_api_init' );
function eg_setting_section_callback_function() {
echo '<p>Intro text for our settings section</p>';
}
function eg_setting_callback_function() {
echo '<input name="eg_setting_name" id="eg_setting_name" type="checkbox" value="1" class="code" ' . checked( 1, get_option( 'eg_setting_name' ), false ) . ' /> Explanation text';
}
But the problem is that I dont know how to position this so it is displayed directly underneath the posts dropdown.
There is no way to add your code in between the Default settings because these settings comes from file /wp-admin/options-reading.php as a whole page and there is not add_action’s to add your custom section between them.
The option left is to do changes in core files but it not advisable.
You can only use jQuery to move your section wherever want.