i need categorize search result of wordpress, have done through adding categories posts , custom post types. now, pages listing without category, think possible add category pages well, not aware of consequences.
kindly share thoughts , experience.
thank you
wordpress doesn't provides option create category in pages .
one thing can done modification in search query search in pages only.
function searchfilter($query) { if ($query->is_search) { $query->set('post_type', 'page'); } return $query; } add_filter('pre_get_posts','searchfilter'); add hook on specific conditions, when want pages displayed in searches.
other side display other pages . in have exclude pages id's
function searchfilter($query) { if ($query->is_search) { $excludeid = array(23,23,23); $query->set('post__not_in', array($excludeid)); } return $query; } add_filter('pre_get_posts','searchfilter');
Comments
Post a Comment