Reputation: 31
the WordPress Theme I am using has some custom post types that come as part of an aditional plugin. Those post types are not available for indexing with Algolia. Can I add them for indexing to the searchable_posts index somehow?
I guess this is the relevant code in the plugin:
private function init() {
$this->setup_constants();
// Actions
add_action( 'plugins_loaded', array( $this, 'load_languages' ), 11 );
add_action( 'init', array( $this, 'init_settings' ), 99 );
add_action( 'init', array( $this, 'register_post_type' ), 100 );
add_action( 'init', array( $this, 'register_taxonomies' ), 101 );
add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes_function' ) );
add_action( 'pre_post_update', array( $this, 'pre_post_update_function' ), 10, 2 );
add_action( 'save_post', array( $this, 'save_meta_box_data' ) );
add_action( 'edit_form_after_title', array( $this, 'add_meta_box_after_title' ) );
add_action( 'admin_menu', array( $this, 'change_destination_menu' ) );
add_action( 'edit_form_top', array( $this, 'edit_form_top_func' ) ); // need to tabs output
add_action( 'pre_get_posts', array( $this, 'sort_destinations_by_meta_value' ) );
add_action( 'wp_footer', array( $this, 'language_switcher_fix' ) );
// Filters
add_filter( 'template_include', array( $this, 'para_destination_templates') );
add_filter( 'request', array( $this, 'alter_the_query' ) );
add_filter( 'wp_title', array( $this, 'page_name_wp_title' ), 10, 2 );
add_filter( 'wp_link_query', array($this, 'wp_link_query_destination' ), 10, 2 );
add_filter( 'oembed_discovery_links', array($this, 'oembed_discovery_links_rf' ), 10, 2 );
add_filter( 'previous_post_rel_link', array( $this, 'previous_post_rel_link_rf' ) );
add_filter( 'next_post_rel_link', array( $this, 'next_post_rel_link_rf' ) );
add_filter( 'wp_get_nav_menu_items', array($this, 'fix_menu_url_info_pages'), 10, 3 );
add_filter( 'preview_post_link', array($this, 'fix_preview_link' ) );
// WP Init
add_action( 'init', array( $this, 'load_scripts' ) );
// Settings
$this->settings = get_destination_settings();
// Create objects
$this->master = new Travel_Master_Pages_CPT( $this->settings );
$this->list = new Travel_Directory_CPT( $this->settings );
$this->map = new Destination_Maps( $this->settings, false );
// Compatibility
$this->backward();
}
Upvotes: 1
Views: 677
Reputation: 798
By default, the searchable posts index will contain all post types that are not flagged as excluded from search.
Here is the exact code line we use to fetch those:
$searchable_post_types = get_post_types( array( 'exclude_from_search' => false ), 'names' );
The only way to index post types that are excluded from search is to make sure that the post type isn't excluded from search anymore:
<?php
// functions.php
add_action( 'init', 'update_my_custom_type', 99 );
function update_my_custom_type() {
global $wp_post_types;
if ( post_type_exists( 'my-custom-type' ) ) {
// exclude from search results
$wp_post_types['my-custom-type']->exclude_from_search = false;
}
}
Upvotes: 1