Skip to content

Instantly share code, notes, and snippets.

@SamuelHadsall
Created May 1, 2024 19:37
Show Gist options
  • Save SamuelHadsall/177611f36092921e87e5de8547da83af to your computer and use it in GitHub Desktop.
Save SamuelHadsall/177611f36092921e87e5de8547da83af to your computer and use it in GitHub Desktop.
Post type and redirects
public function uni_market_post_type() {
$names = [
'name' => 'market',
'singular' => 'Market',
'plural' => 'Markets',
'slug' => 'market',
];
$options = [
'has_archive' => true,
'query_var' => true,
'publicly_queryable' => true,
'hierarchical' => true,
'capability_type' => 'page',
'show_in_menu' => $this->plugin_name,
'show_in_graphql' => true, # Set to false if you want to exclude this type from the GraphQL Schema
'graphql_single_name' => 'market',
'graphql_plural_name' => 'markets', # If set to the same name as graphql_single_name, the field name will default to `all${graphql_single_name}`, i.e. `allDocument`.
'rewrite' => false,
'supports' => [
'title',
'page-attributes'
],
'menu_icon' => 'dashicons-store',
];
$locations = new PostType( $names, $options );
$locations->register();
}
public function uni_state_post_type() {
$names = [
'name' => 'state',
'singular' => 'State',
'plural' => 'States',
'slug' => 'state',
];
$options = [
'has_archive' => false,
'query_var' => true,
'publicly_queryable' => true,
'hierarchical' => true,
'capability_type' => 'page',
'show_in_menu' => $this->plugin_name,
'show_in_graphql' => true, # Set to false if you want to exclude this type from the GraphQL Schema
'graphql_single_name' => 'state',
'graphql_plural_name' => 'states', # If set to the same name as graphql_single_name, the field name will default to `all${graphql_single_name}`, i.e. `allDocument`.t
'rewrite' => false,
'supports' => [
'title',
'page-attributes'
],
'menu_icon' => 'dashicons-location',
];
$locations = new PostType( $names, $options );
$locations->register();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment