I’ve a customized put up sort referred to as integrations
, which is getting used to host fundamental data for integrations.
This is how I’ve registered the put up sort:
register_post_type(
'Integrations',
theme_build_post_args(
// $slug, $singular, $plural
'integrations', 'Integration', 'Integrations',
array(
'menu_position' => 21,
'has_archive' => false,
'public' => false,
'hierarchical' => false,
'helps' => array('title', 'revisions'),
'taxonomies' => array('classes'),
)
)
);
Now, I even have a web page referred to as “Integrations” which sits on /integrations
. So as to make the archive web page use the web page template as a substitute, I’ve used template_include
:
operate custom_integrations_template( $template ) {
if ( is_page( 'integrations' ) ) {
$new_template = locate_template( array( 'integration-page-template.php' ) );
if ( '' != $new_template ) {
return $new_template ;
}
}
return $template;
}
add_filter( 'template_include', 'custom_integrations_template', 999 );
integration-page-template.php
:
<?php get_header(); ?>
<?php whereas ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php get_footer(); ?>
Now, this is the place my points start.
Beneath the “Integrations” customized put up sort, I’ve a put up referred to as “TaxCalc”, which sits on /integrations/taxcalc/
.
Nonetheless, I additionally have to create a web page, which will likely be a toddler of the “Integrations” web page which sits on /integrations/taxcalc/
.
Presently, after I entry /integrations/taxcalc/
, it takes me to a clean web page, which is the put up model.
Ideally, I don’t need the posts beneath the “Integrations” put up sort to generate any URLs. To do that, I’ve tried 'publicly_queryable' => false
, nonetheless, it doesn’t do something.
How can I stop a put up sort from producing URLs and would this trigger any knock on results? For instance, stop me from creating pages beneath the identical slug?
Edit (response to @Lewis)
Thanks for the reply. I’ve added 'rewrite' => false
, however the concern nonetheless stays.
Under is an integration put up and you’ll see the permalink within the screenshot too:
Once I go to that permalink /integrations/card-taxcalc/
, it takes me to a web page with simply the header and footer. Ideally, this put up should not exist.
Now, beneath is a screenshot of my TaxCalc web page setup:
As you’ll be able to see, this web page sits on /integrations/taxcalc/
. Nonetheless, after I go to this URL, it redirects me to /integrations/card-taxcalc/
Edit 2
theme_build_post_args
:
class theme_PTTaxArgBuilder{
/**
* Choices will likely be merged into these, versus utilizing
* the usual WordPress defaults.
* @var array
*/
public $postDefaults = array(
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => '' ),
'capability_type' => 'put up',
'has_archive' => true,
'hierarchical' => false,
'helps' => array( 'title', 'editor', 'writer', 'excerpt', 'thumbnail' ),
);
/**
* Choices will likely be merged into these, versus utilizing
* the usual WordPress defaults.
* @var array
*/
public $taxonomyDefaults = array(
'hierarchical' => true,
'show_ui' => true,
'show_admin_column' => true,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array( 'slug' => '' ),
);
/**
* Construct the put up sorts labels primarily based solely on the capitalised
* singular and plural kind.
* @param string $singular Singular & capitalised kind for the put up sort, eg 'Put up'
* @param string $plural Plural & capitalised kind for the put up sort, eg 'Posts'
*/
public operate buildPostLabels( $singular="Put up", $plural="Posts" )
{
if($singular != 'Put up' && $plural == 'Posts' ) {
$plural = $singular . 's';
}
$labels = array(
'title' => _x($plural, 'put up sort normal title', 'lightbox'),
'singular_name' => _x($singular, 'put up sort singular title', 'lightbox'),
'menu_name' => _x($plural, 'admin menu', 'lightbox'),
'name_admin_bar' => _x($singular, 'add new on admin bar', 'lightbox'),
'add_new' => _x('Add New', $singular, 'lightbox'),
'add_new_item' => __('Add New ' . $singular, 'lightbox'),
'new_item' => __('New ' . $singular, 'lightbox'),
'edit_item' => __('Edit ' . $singular, 'lightbox'),
'view_item' => __('View ' . $singular, 'lightbox'),
'all_items' => __('All ' . $plural, 'lightbox'),
'search_items' => __('Search ' . $plural, 'lightbox'),
'parent_item_colon' => __('Mum or dad ' . $plural . ':', 'lightbox'),
'not_found' => __('No ' . strtolower($plural) . ' discovered.', 'lightbox'),
'not_found_in_trash' => __('No ' . strtolower($plural) . ' present in Trash.', 'lightbox'),
);
return $labels;
}
/**
* Generate the entire arguments prepared for put up sort creation,
* together with the URL slug and merging of recent defaults above.
* @param string $slug The URL slug for the put up sort, eg 'posts'
* @param string $singular Singular & capitalised kind for the put up sort, eg 'Put up'
* @param string $plural Plural & capitalised kind for the put up sort, eg 'Posts'
* @param array $args Further arguments to override the defaults
*/
public operate buildPostArgs( $slug, $singular="Put up", $plural="Posts", $args = array() )
{
$args = wp_parse_args($args, $this->postDefaults);
$args['rewrite']['slug'] = $slug;
$args['labels'] = $this->buildPostLabels($singular, $plural);
return $args;
}
/**
* Construct the taxonomies labels primarily based solely on the capitalised
* singular and plural kind.
* @param string $singular Singular & capitalised kind for the taxonomy, eg 'Class'
* @param string $plural Plural & capitalised kind for the taxonomy, eg 'Classes'
*/
public operate buildTaxonomyLabels( $singular="Class", $plural="Classes" )
{
if($singular != 'Class' && $plural == 'Classes' ) {
$plural = $singular . 's';
}
$labels = array(
'title' => _x($plural, 'taxonomy normal title'),
'singular_name' => _x($singular, 'taxonomy singular title'),
'search_items' => __('Search ' . $plural),
'all_items' => __('All ' . $plural),
'parent_item' => __('Mum or dad ' . $singular),
'parent_item_colon' => __('Mum or dad ' . $singular . ':'),
'edit_item' => __('Edit ' . $singular),
'update_item' => __('Replace ' . $singular),
'add_new_item' => __('Add New ' . $singular),
'new_item_name' => __('New ' . $singular . ' Title'),
'menu_name' => __($plural),
// Tags
'popular_items' => __('Standard ' . $plural),
'separate_items_with_commas' => __('Separate ' . strtolower($plural) . ' with commas'),
'add_or_remove_items' => __('Add or take away ' . strtolower($plural)),
'choose_from_most_used' => __('Select from essentially the most used ' . strtolower($plural)),
'not_found' => __('No ' . strtolower($plural) . ' discovered.'),
);
return $labels;
}
/**
* Generate the entire arguments prepared for taxonomy creation,
* together with the URL slug and merging of recent defaults above.
* @param string $slug The URL slug for the taxonomy, eg 'class'
* @param string $singular Singular & capitalised kind for the taxonomy, eg 'Class'
* @param string $plural Plural & capitalised kind for the taxonomy, eg 'Classes'
* @param array $args Further arguments to override the defaults
*/
public operate buildTaxonomyArgs( $slug, $singular="Class", $plural="Classes", $args = array() )
{
$args = wp_parse_args($args, $this->taxonomyDefaults);
$args['rewrite']['slug'] = $slug;
$args['labels'] = $this->buildTaxonomyLabels($singular, $plural);
return $args;
}
}
/**
* These public capabilities exist as procedural capabilities to maintain in fashion
* with WordPress theme improvement.
*/
operate theme_build_post_args( $slug, $singular="Put up", $plural="Posts", $args = array() )
{
$builder = new theme_PTTaxArgBuilder;
return $builder->buildPostArgs($slug, $singular, $plural, $args);
}