Is there possible way to modify custom post type?

I use a third party plugin and plugin has created a custom post type called "creations".Bu there is no archive

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)

Share Improve this question edited Jul 17, 2019 at 5:20 I am the Most Stupid Person asked Jul 10, 2019 at 5:46 I am the Most Stupid PersonI am the Most Stupid Person 5681 gold badge7 silver badges30 bronze badges 2
  • You can create templates for archive and single pages. For the admin page you have to examine the plugin for available hooks responsible for the admin page or ask the plugin developer. – Max Yudin Commented Jul 10, 2019 at 7:12
  • 1 You could use register_post_type_args or registered_post_type to modify the post type data. – Sally CJ Commented Jul 17, 2019 at 9:10
Add a comment  | 

2 Answers 2

Reset to default 12 +50

You 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

相关推荐

  • Is there possible way to modify custom post type?

    I use a third party plugin and plugin has created a custom post type called "creations".Bu there is no archive

    13小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信