2015-05-21, 20:54:27
(This post was last modified: 2015-05-22, 03:58:35 by icedaddy.
Edit Reason: Workaround found
)
Hi
I have a special page with a special page extra field - Catagory, which is a multi-select list. I want to be able to search (using i18n_Search) on a catagory term. I have set the field index 'as tag' but it does not appear to be setting the values as tag data.
Also, a multi-link (URL) field would be nice in order to add multiple links to other pages.
Thanks
UPDATE:
It appears it does work for single entry fields. But if you select more than 1 item in a multi-select list the search does not resolve the individual entried.
For example:
my Catagory multi-select field has possible value: item1, item2 and item3
if I select 'item1' on a page and search for 'item1' it works;
if I select 'item1' and 'item3' and search for 'item1' it fails; however it will find the page if I search for 'item1||item3'
UPDATE - WORKAROUND:
I have found a workaround for this problem, if anyone else has this issue. Put the following code at the top of the template.php file in your theme:
<?php
/**
* Fix searching on multi-select special fields
*/
add_filter('search-index-page', 'cat_search_indexing');
function cat_search_indexing($item) {
// add category items to tag lists
if ($item->category) {
$tags = explode("||", $item->category);
$item->addTags('page_tags', $tags);
}
}
?>
Would be nice to see this fixed in the plugin on the next update though.
I have a special page with a special page extra field - Catagory, which is a multi-select list. I want to be able to search (using i18n_Search) on a catagory term. I have set the field index 'as tag' but it does not appear to be setting the values as tag data.
Also, a multi-link (URL) field would be nice in order to add multiple links to other pages.
Thanks
UPDATE:
It appears it does work for single entry fields. But if you select more than 1 item in a multi-select list the search does not resolve the individual entried.
For example:
my Catagory multi-select field has possible value: item1, item2 and item3
if I select 'item1' on a page and search for 'item1' it works;
if I select 'item1' and 'item3' and search for 'item1' it fails; however it will find the page if I search for 'item1||item3'
UPDATE - WORKAROUND:
I have found a workaround for this problem, if anyone else has this issue. Put the following code at the top of the template.php file in your theme:
<?php
/**
* Fix searching on multi-select special fields
*/
add_filter('search-index-page', 'cat_search_indexing');
function cat_search_indexing($item) {
// add category items to tag lists
if ($item->category) {
$tags = explode("||", $item->category);
$item->addTags('page_tags', $tags);
}
}
?>
Would be nice to see this fixed in the plugin on the next update though.