Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon How do I find the IDs of the post types I want to exclude


How do I find the IDs of the post types I want to exclude


To find the IDs of the post types you want to exclude from the Yoast SEO sitemap, you can follow these steps:

1. Use the WordPress Admin Dashboard:
- Log in to your WordPress admin dashboard.
- Go to Posts > All Posts or Pages > All Pages.
- Click on the post type you want to exclude.
- In the post's metadata, you will find the post ID in the URL. For example, if the URL is `https://yourwebsite.com/wp-admin/post.php?post=1234`, the post ID is `1234`.

2. Use the WordPress Codex:
- Open the WordPress Codex documentation.
- Search for the term "post ID" or "post type ID".
- The Codex provides detailed information on how to find and use post IDs.

3. Use a Plugin or Custom Function:
- Install a plugin like WP Post ID Finder or Post ID Finder.
- Use a custom function in your theme's `functions.php` file to retrieve the post IDs.

Here is an example of how to use a custom function to find the post IDs:

php
function get_post_ids() {
    $post_ids = array();
    $args = array(
        'post_type' => 'post_type_slug',
        'posts_per_page' => -1
    );
    $query = new WP_Query( $args );
    if ( $query->have_posts() ) {
        while ( $query->have_posts() ) {
            $query->the_post();
            $post_ids[] = get_the_ID();
        }
    }
    return $post_ids;
}

Replace `'post_type_slug'` with the slug of the post type you want to exclude.

Citations:
[1] https://www.binarycarpenter.com/how-to-exclude-custom-post-types-posts-pages-from-yoast-seo-sitemap/
[2] https://wordpress.stackexchange.com/questions/243476/exclude-custom-post-type-in-sitemap-generation
[3] https://clicknathan.com/web-design/ocho_no_individual_testimonials_in_sitemap/
[4] https://stackoverflow.com/questions/44530358/wordpress-yoast-exclude-posts-from-xml-sitemap
[5] https://yoast.com/help/sitemap-shows-excluded-posts-pages/