• Resolved dnuon

    (@dnuon)


    I created a custom post type “Editable Areas” and set the exclude_from_search to TRUE. But when I try a search it INCLUDES the custom post type. Below is the function code:

    $args = array(
            'labels' => $labels,
            'hierarchical' => false,
            'description' => 'Edit the footer and global sidebar items here',
            'supports' => array( 'title', 'editor' ),
            'public' => false,
            'show_ui' => true,
            'show_in_menu' => true,
            'menu_position' => 20,
            'show_in_nav_menus' => false,
            'publicly_queryable' => false,
            'exclude_from_search' => true,
            'has_archive' => false,
            'query_var' => false,
            'can_export' => true,
            'rewrite' => true,
            'capability_type' => 'post'

    Running WP 3.4, no custom post type plugins or search altering plugins. Simple WP setup with a few plugins but nothing that should interfere with the custom post type and search function.
    Any help is appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter dnuon

    (@dnuon)

    … that’s frustrating. It’s working now all of a sudden…
    No changes made, just left for lunch and came back to try it again…

    Thread Starter dnuon

    (@dnuon)

    NVM, it’s not working. I forgot I added in a filter to only search regular post and pages.

    function SearchFilter($query) {
    if ($query->is_search) {
    $query->set('post_type', array( 'post', 'page'));
    }
    return $query;
    }
    
    add_filter('pre_get_posts','SearchFilter');

    Still need help in getting this to work normally without the filter function…
    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Post type 'exclude_from_search'=>true not working’ is closed to new replies.