Splitting do_settings_sections within HTML?


This seems like it should be very simple to achieve, but I have spent far too long trying to figure it out. I have two settings sections:

add_settings_section( 'cp_required_info', 'One', array($this, 'cp_required_info'), 'cp-settings' );
add_settings_section( 'cp_sync_info', 'Two', array($this, 'cp_sync_info'), 'cp-settings' );
register_setting( 'cp-settings', 'cp_admin_options', array( $this, 'sanitize' ) );

How can I get these sections to output in different locations in the HTML? do_settings_sections is only allowing $page. I have tried do_settings_fields which allows for $page and $section and it does achieve what I want, however when I remove the do_settings_section and leave only the do_settings_fields, all of my output disappears. Below is an example of what I am trying to achieve.

<?php settings_fields( 'cp-settings' );   
//do_settings_sections( 'cp-settings' );
do_settings_fields( 'cp-settings', 'cp_required_info' );?>

<!--Some HTML goes here-->

do_settings_fields( 'cp-settings', 'cp_sync_info' );?>

Does anyone know how to achieve this? All of my callbacks are functioning properly, its just a matter of placing the sections on the page.

EDIT: Including the add_settings_fields:

public function cp_required_info() {
        add_settings_field( 'cp_apikey', 'API Key:', array( $this, 'cp_apikey_callback' ), 'cp-settings', 'cp_required_info', array( 'label_for' => 'cp_apikey') );      
        add_settings_field( 'cp_username', 'Username:', array( $this, 'cp_username_callback' ), 'cp-settings', 'cp_required_info', array( 'label_for' => 'cp_username') );      
        add_settings_field( 'cp_tablename', 'Table Name:', array( $this, 'cp_tablename_callback' ), 'cp-settings', 'cp_required_info', array( 'label_for' => 'cp_tablename') );      

public function cp_sync_info() {
        add_settings_field('cp_collect_posts', 'Posts', array($this, 'cp_posts_callback'), 'cp-settings', 'cp_sync_info', array( 'label_for' => 'cp_collect_posts') );
user82238 8 years 2015-10-20T10:13:23-05:00 0 Answers 103 views 0

Leave an answer