'How can I display custom posts as a sortable table with PHP for WordPress? [closed]
Ideally, I'm trying to do this with a plugin and then assign the table to a shortcode which I can use anywhere on a website.
Here's my generic code to add a custom post type:
<?PHP
function create_post_type_customers(){
// Set UI labels for CPT
$labels = array(
'name' => __('Customers'),
'singular_name' => __('Customer'),
'menu_name' => __('Customers'),
'parent_item_colon' => __('All Customers'),
'all_items' => __('All Customers'),
'view_item' => __('View Customer'),
'add_new_item' => __('Add New Customer'),
'add_new' => __('Add New'),
'edit_item' => __('Edit Customer'),
'update_item' => __('Update Customer'),
'search_items' => __('Search Customers'),
'not_found' => __('Not Found'),
'not_found_in_trash' => __('Not Found in Trash'),
);
// CPT Options
$args = array(
'label' => __('customers'),
'description' => __('Freedom Search Customers'),
'labels' => $labels,
'supports' => array('title', 'editor', 'revisions', 'custom-fields'),
'taxonomies' => array('test'),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menu' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'has_archive' => true,
'rewrite' => array('slug' => 'customers'),
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
'show_in_rest' => true,
);
register_post_type('Customers', $args);
}
add_action('init', 'create_post_type_customers', 0);
?>
I am fairly new to PHP and WordPress development, so some general direction would be brilliant, if not a full solution.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
