0

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.

  • 1
    WordPress doesn't generate XML sitemaps (yet). So any modifications to this behaviour would depend on the plugin. Since 3rd party plugins are off-topic here, I'd suggest contacting the plugin author or using their support forum. – Jacob Peattie Jun 14 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.