I use a third party plugin and plugin has created a custom post type called "creations".
Bu there is no archive page, there is no single page, there is no admin menu page... But data are saving on database correctly.
Is there a possible way to the active admin menu, archive page & single page?
Other all behaviours of custom post type should be there like( Eg: if exclude_from_search
is true, this shouldn't change)
I use a third party plugin and plugin has created a custom post type called "creations".
Bu there is no archive page, there is no single page, there is no admin menu page... But data are saving on database correctly.
Is there a possible way to the active admin menu, archive page & single page?
Other all behaviours of custom post type should be there like( Eg: if exclude_from_search
is true, this shouldn't change)
2 Answers
Reset to default 12 +50You can change register_post_type()
arguments before the new type is created. To do this, use the register_post_type_args
filter.
add_filter( 'register_post_type_args', 'se342540_change_post_type_args', 10, 2 );
function se342540_change_post_type_args( $args, $post_name )
{
if ( $post_name != 'cpt_slug' )
return $args;
$args['has_archive'] = true;
//
// other arguments
return $args;
}
If the plugin only registers the CPT, remove it and build your own.
If the plugin does other things you need to keep on your site, you can unregister the post type and re-register it with your own plugin. You'll just need to keep in mind that changing settings may affect the way the original plugin works - it may rely on certain options in the CPT.
Either way, copy the part of the plugin that registers the CPT and then adjust just the options you need. Make sure to replace "post_type" below with the actual CPT name.
<?php
// Optionally unregister the post type to clear all settings
// (this does not delete any of the posts from the database)
unregister_post_type( 'post_type' );
// Now, re-register it as in the plugin, but with
// the adjusted settings you need
$args = array(
// has_archive will provide an archive page
'has_archive' => true,
// 'supports' will enable an Editor for single pages
'supports' => array('title', 'editor', 'author', 'revisions', 'page-attributes'),
// 'public' makes it available in a number of places like menus
'public' => true
);
register_post_type( 'post_type', $args );
?>
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745313369a4622102.html
register_post_type_args
orregistered_post_type
to modify the post type data. – Sally CJ Commented Jul 17, 2019 at 9:10