WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#20234 closed defect (bug) (duplicate)

'exclude_from_search' parameter for custom posts makes taxonomy archive pages return 0 posts

Reported by: egorpromo Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.3.1
Component: Posts, Post Types Keywords:
Focuses: Cc:

Description

I have custom posts 'manuals' and taxonomy 'manuals-category' for it.

add_action( 'init', 'create_manual_post_type' );
function create_manual_post_type()
{
	register_post_type('manual', 
		array(	
			'label' => 'Manuals',
			'public' => TRUE,
			'rewrite' => array( 'slug' => 'manuals', 'with_front' => true),
			'has_archive' => true,
			'public' => true,
			'exclude_from_search' => TRUE, //This is for exclude my manuals when I make search for word 'wordpress' like "http://myblog.com/?s=wordpress&submit=submit"
		) 
	);

	register_taxonomy(
'manuals-category',
'manual',
		array(
			'hierarchical'=>false,
			'label'=>'Manual Category',
			'rewrite' => array( 'slug' => 'manuals-category', 'with_front' => true)
			)
);

	flush_rewrite_rules(false);

}

I want use 'exclude_from_search' parameter to prevent custom posts are visible when somebody searches keywords in my blog.
If I state 'exclude_from_search'=>TRUE my custom posts disappear on pages like http://myblog.com/manuals-category/{slug}.
{slug} is a term of 'manuals-category' taxonomy. Archive page opens but there are no posts in the Loop. When I state 'exclude_from_search'=>FALSE all is correct.

I suppose it is not documented behavior http://codex.wordpress.org/Function_Reference/register_post_type and bug.

Change History (1)

comment:1 ocean902 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.