Have custom post type posts show under regular posts in sitemap (Yoast)

by Coltvant   Last Updated June 14, 2019 16:08 PM

I have a custom post type called FAQs, and I'm using Yoast SEO to generate a sitemap. The sitemap gets generated like it should, but it creates a completely separate sitemap for the FAQ post type, so example.com/faq-sitemap.xml. That makes sense, but I'm wondering if there's a way I could keep the custom post type of FAQ but have the FAQ posts show up under the example.com/post-sitemap.xml instead, and then example.com/faq-sitemap.xml wouldn't even exist anymore.

Here's the code to create the custom post type.

function create_faq_post_type() {
// Set UI labels for Custom Post Type
$labels = array(
    'name'                => _x( 'FAQs', 'Post Type General Name' ),
    'singular_name'       => _x( 'FAQ', 'Post Type Singular Name' ),
    'menu_name'           => __( 'FAQs' ),
    'parent_item_colon'   => __( 'Parent FAQ' ),
    'all_items'           => __( 'All FAQs' ),
    'view_item'           => __( 'View FAQ' ),
    'add_new_item'        => __( 'Add New FAQ' ),
    'add_new'             => __( 'Add New' ),
    'edit_item'           => __( 'Edit FAQ' ),
    'update_item'         => __( 'Update FAQ' ),
    'search_items'        => __( 'Search FAQ' ),
    'not_found'           => __( 'Not Found' ),
    'not_found_in_trash'  => __( 'Not found in Trash' )
);

// Set other options for Custom Post Type
$args = array(
    'label'               => __( 'faqs' ),
    'description'         => __( 'frequently asked questions' ),
    'labels'              => $labels,
    // Features this CPT supports in Post Editor
    'supports'            => array( 'title', 'editor', 'thumbnail', 'author', 'comments', 'custom-fields' ),
    'hierarchical'        => true,
    'public'              => true,
    'show_ui'             => true,
    'show_in_menu'        => true,
    'show_in_nav_menus'   => true,
    'show_in_admin_bar'   => true,
    'menu_position'       => 5,
    'can_export'          => true,
    'has_archive'         => true,
    'exclude_from_search' => false,
    'publicly_queryable'  => true,
    'taxonomies'  => array( 'category', 'post_tag' ),
    'rewrite' => array('slug' => '%category%')
);

// Registering faq custom post type
register_post_type( 'faq', $args );
}

// Hooking up the faq custom post type function to theme setup
add_action( 'init', 'create_faq_post_type', 0 );

Kind of a weird request, but that's what the SEO is wanting to do unfortunately.



Related Questions


How To Improve Your Google Rankings

Updated August 25, 2017 10:08 AM

Changing Post Sitemap Frequency to Hourly

Updated July 11, 2015 17:03 PM

How to make a corn job for the sitemap?

Updated July 07, 2018 18:08 PM

Yoast seo adds two empty lines in sitemap_index.xml

Updated August 22, 2016 08:05 AM

how to remove white space above the code

Updated April 15, 2017 19:08 PM