I am trying to get Pages, Posts and Custom Post Types In WordPress website but it is showing some other things in the list.
My Code:
<?php $types = get_post_types( ['public' => true ], 'objects' );
foreach ( $types as $type ) {
if ( isset( $type->labels->name) ) { ?>
<?php echo $type->labels->name ?>
<br>
<?php }
} ?>
In this, I am getting:
Posts
Pages
Media
My Templates
Locations
But I only want Pages, Posts and Locations (Locations is the Custom Post Type).
Any help is much appreciated.
attachment
in the database. I don't know whatMy Templates
is though, knowing more information about each post type would help, but there's a good chance that it's being added by a 3rd party plugin