Search code examples
wordpresswordpress-rest-api

Add extra field type in wordpress back end


read mark places i want to add extra two fields. that is Liked and Unliked How can i do it??

My register post type is:

`register_post_type('faq-page', array(

        'labels' => array(

            'name' => 'FAQ',
            'add_new_item' => 'Add New FAQ',
            'add_new' => 'Add New FAQ',
            'all_items' => 'All FAQ',
        ),

        'public' => true,
        'show_in_rest' => true,
        'supports' => array('title','editor'),
        'menu_icon' => 'dashicons-plus',
    ));`

Solution

  • you need to use manage_[post_type]_posts_columns hook. Take a look at the WP documentation - https://developer.wordpress.org/reference/hooks/manage_post_type_posts_columns/ . Also take a look at this article where you can get a good example on how to use this hook for custom post types - https://www.smashingmagazine.com/2017/12/customizing-admin-columns-wordpress/ I think it's exactly what you need.