How to sign out of WordPress custom article types and custom classifications

Many WordPress themes come with their own custom article types. Such as frequently asked questions (FAQ), Portfolio or anything else. Installing themes forces you to deal with those additional custom article types and classifications. Some themes allow you to disable them, while others do not. Today, let’s learn how to cancel custom article types or custom classifications in any topic.

First, we need to find the article type or classification name. Navigate to a custom article type or custom classification (such as categories, tags), and view the URL.

How to sign out of WordPress custom article types and custom classifications

post_type Value after parameter faq This is the name of this custom article type, which will be used below.

How to sign out of WordPress custom article types and custom classifications

taxonomy the value of the parameter faq_category This is the name of the custom classification system, which will be used below.

Now that we know the name of the article type/classification, we can unsign it from WordPress.

Sign out of custom article types and custom categories

Starting from WordPress 4.5, there are functions unregister_post_type() andunregister_taxonomy() This can be done. In the currently enabled theme’sfunctions.phpSimply paste the following code in:

function wpdaxue_deregister_post_type(){
  unregister_post_type ('faq ' ); //Unregister faq Article type
  unregister_taxonomy ('faq_category'); //unregister the faq_category classification
}
add_action('init','wpdaxue_deregister_post_type');

That’s it! Just replace “faq” and “faq_category” with your article type and classification name. In the WordPress management backend, you will see that the custom article type/classification no longer exists.

Please note that usingunregister_post_type()orunregister_taxonomy()The function does not clean up at installation time-it does not delete any data from the database. To do this, you can use the following query to manually delete these records:DELETE FROM wp_posts WHERE post_type ='[Your custom post type]

Or follow the article action: Delete article data for custom article types that are no longer used in WordPress

The last thing to do is to save your permallinks again to refresh them.

Remove Portfolio and FAQ custom article types from Avada topics.

If you are running an Avada WordPress theme and want to remove Portfolio and FAQ custom article types and their custom classifications, you can use the following code:

function wpdaxue_deregister_post_type(){
  unregister_post_type( 'avada_portfolio' );
  unregister_post_type( 'avada_faq' );
  unregister_taxonomy( 'portfolio_category');
  unregister_taxonomy( 'portfolio_tags');
  unregister_taxonomy( 'portfolio_skills');
  unregister_taxonomy( 'faq_category');
}
add_action('init','wpdaxue_deregister_post_type');

For more information about the two functions described in the text, visit:

  • unregister_post_type()
  • unregister_taxnonomy()

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注