Support

Account

Home Forums Backend Issues (wp-admin) Tips for making custom form fields look good in admin?

Helping

Tips for making custom form fields look good in admin?

  • Hi, I’m using acf to display custom form fields in the admin for a custom post type. When an admin clicks on add “new myposttype” the page shows up with just the custom form fields. Is there a way to add titles or breaks between the fields?

    Note that this page will show just my custom fields. Everything else is hidden.

    Thanks for any help!

    PK

  • Hi @preserved

    You can add HTML to any WP page by hooking into the ‘admin_footer’ action, checking that the url is correct for the page you want, and then injecting extra HTML into the page. Here’s a idea of the code:

    add_action('admin_footer', 'my_admin_footer');
    
    function my_admin_footer() {
    	
    	// vars
    	$page = 'acf-options-cwl-settings';
    	
    	
    	// bail early if not correct page
    	if( empty($_GET['page']) || $_GET['page'] !== $page ) {
    		
    		return;
    		
    	}
    	
    	
    ?>
    <div id="my-html">
    	<p>test</p>
    </div>
    <script type="text/javascript">
    (function($) {
    	
    	// move #my-html
    	$('#post-body-content').append( $('#my-html') );
    	
    })(jQuery);	
    </script>
    <?php
    	
    }
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.