Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $args = array(
- 'labels' => $labels,
- 'supports' => array( 'title', 'editor' ),
- 'hierarchical' => false,
- 'public' => true,
- 'show_ui' => false,
- 'show_in_menu' => false,
- 'menu_position' => 5,
- 'show_in_admin_bar' => false,
- 'show_in_nav_menus' => false,
- 'can_export' => true,
- 'has_archive' => true,
- 'exclude_from_search' => false,
- 'publicly_queryable' => true,
- 'capability_type' => 'post',
- );
- register_post_type( 'taxarchive', $args );
- $taxonomies = $wpdb->get_results("SELECT term_id, name FROM $wpdb->terms");
- $taxonomies_array = array();
- wp_defer_term_counting(true);
- foreach ($taxonomies as $taxonomy) {
- $term = get_term($taxonomy->term_id);
- $taxonomy = get_taxonomy($term->taxonomy);
- if(isset($term->taxonomy) && $taxonomy->publicly_queryable) {
- $taxonomies_array[$taxonomy->name] = $term->taxonomy;
- $term_post = array(
- 'post_title' => $term->name,
- 'post_content' => $term->name,
- 'post_status' => 'publish',
- 'post_type' => 'taxarchive'
- );
- if(post_exists($term->name) == 0) {
- wp_insert_post($term_post);
- }
- }
- }
- wp_defer_term_counting(false);
- function add_post_type_to_search( $query ) {
- if ( is_admin() || ! $query->is_main_query() ) {
- return;
- }
- $args = array(
- 'exclude_from_search' => false,
- );
- $post_types = get_post_types( $args, 'names', 'and' );
- print_r($post_types);
- $query->set(
- 'post_type', array_values($post_types)
- );
- // print_r($query);
- }
- add_filter( 'pre_get_posts', 'add_post_type_to_search' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement