Show custom post type on post category page doesn’t work / breaks navigation

The reason the menu is disappearing is because pre_get_posts applies to all queries on the page, including menus, your code is interferring with the menu queries. The is_main_query method should make sure it only affect the query in the loop, which in most cases will be the query displaying the posts. function test_add_cpt_to_archive_page( $query ) … Read more

Develop theme with demo default content, programmatically create pages

use after_setup_theme create your post and tags then save the data, add option key and only run your setup once, i.e. add_action( ‘after_setup_theme’, function() { $setupKey = ‘my_theme_activated’; $setupAlreadyRun = get_option($setupKey); if ( $setupAlreadyRun ) return; my_theme_setup( $setupKey ); }); function my_theme_setup( $setupKey ) { $posts = [ [ ‘post_title’ => ‘Project Page’, ‘post_type’ => … Read more