• I’m interested in creating some code that will add a menu option to the back-end, similar to posts and pages. Clicking it will produce a list just like posts and pages, except this will be to new content which when edited will be a set of fields, rather than the block editor.

    I’ve seen plugins do this and wonder if they’re using an API of some kind to produce the standard WP style layouts, similar to how we have the Settings APIs.

    Any suggestions on the easiest way to approach this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    You can add admin menu items with add_menu_page(). The callback you specify is responsible for all of the page’s content and processes. The Settings API is one way to achieve a uniform appearance consistent with other admin pages. The problem with the Settings API is it save everything as an option value, you cannot save data elsewhere.

    If you want a custom table similar to the ones for posts and pages, you can extend the WP_List_Table class. Refer to WP_Posts_List_Table source code to see what was done for posts. Do something similar for your data.

    The list table isn’t that conducive to editing table content, though it’s possible. The post quick edit feature is one way to edit table content. It’s probably easier to provide an “Edit” row action link that goes to a separate editor page which contains all the editable fields for that particular row.

    Add the editor page with add_submenu_page(). Link to it from a row action link in a similar way, "https://example.com/wp-admin/admin.php?page=my_menu_slug?data-id=$row_id"

    Hi @dartiss
    You’re looking to create the Custom Post Type (CPT). You may follow the WordPress official documentation.

    Doc: https://developer.www.ads-software.com/plugins/post-types/registering-custom-post-types/

    Give it a try, and let me know how that goes! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to produce a backend list which I can them edit’ is closed to new replies.