1. Customize
  2. Customizations
  3. Disable post type archive for achievements and ranks

Disable post type archive for achievements and ranks

On WordPress, any post type with public access auto-generates an archive page where all published entries are listed.

For example, for the post type “product”, an archive page will be auto-generated on your site on this URL: https://yoursite.com/product

Exactly the same happens with all achievement and rank types registered in your site, for that, there is a code snippet that lets you disable this archive auto-generated.

Disable archive for achievements:

function my_prefix_disable_achievement_post_type_archive( $post_type_args, $achievement_type ) {

    $post_type_args['has_archive'] = false;

    return $post_type_args;

}
add_filter( 'gamipress_achievement_post_type_args', 'my_prefix_disable_achievement_post_type_archive', 10, 2 );

Disable archive for ranks:

function my_prefix_disable_rank_post_type_archive( $post_type_args, $rank_type ) {

    $post_type_args['has_archive'] = false;

    return $post_type_args;

}
add_filter( 'gamipress_rank_post_type_args', 'my_prefix_disable_rank_post_type_archive', 10, 2 );

How can we help?