Hello Toolset-Support,
I found a problem with Views and frontend search. This is a bit complicated and I hope you can understand me. Please let me know if something is unclear.
The toolset setup:
* A custom post type „Snippets“
* A custom taxonomy called „Relations“, used for both: post type „Pages“ and my new custom post type „Snippets“
* A Toolset View which shows the „Snippets“, filtered by taxonomy „Relations“ and the option „the same as the page where this View is shown“.
The content setup:
* A new term for the taxonomy Relations, for example „page-1“
* A „Snippets“ post with some text and the taxonomy term „page-1“
* A standard page „My first page“ with some text and the views shortcode and the taxonomy term „page-1“
The result:
Viewing the page „My first page“ in the frontend it shows some text and the content of my snippet. That works great so far. (Background info: I set it up like this to use the same snippets on many different pages and other custom post types. I only have to give the snippets and the other post types the same taxonomy term).
The goal for the frontend search:
If I search for a term which is only present in a snippet, the search results page should show the page(s), where this snippet is used and not the snippet itself. The custom post type „Snippets“ should never be displayed in the search results.
An now the problem:
Search doesn’t work properly. I tested this with Relevanssi and SearchWP as both plugins have an option to expand shortcodes when indexing. This works with simple shortcodes but doesn’t work with views where a taxonomy is filtered with „the same as the page where this View is shown“.
The problem: after the initial indexing the content of my snippets view isn’t indexed at all. But if I open the page where I use the views shortcode in the editor and just hit „Update“, the snippets content get’s indexed and then can be found in frontend search. After a new re-indexing it’s gone again. This is reproducible with both search plugins.
The big question is: why does the content of my snippet gets indexed only after editing a page where the shortcode is used and not during initial indexing?
Best regards
Matthias
Dear Matthias,
It is a compatibility problem, I need detail steps to duplicate the same problem.
I assume we are talking about the option "Expand shortcodes" of Relevanssi plugin(https://wordpress.org/plugins/relevanssi/):
Dashboard-> Settings-> Relevanssi
option "Expand shortcodes when indexing".
1) How do you setup the post view?
A Toolset View which shows the „Snippets“
Are you using a custom search form in it?
Please take a screenshot for it, especially section "Loop Editor" and section "Search and Pagination"
2) how do you setup the frontend search?
Is it wordpress built-in search or custom search form of above post view?
Please provide detail steps, thanks
Hello Luo,
Thank you for your reply.
Yes: Dashboard-> Settings-> Relevanssi option "Expand shortcodes when indexing".
1) See the screenshot. It's a very simple view. I don't use a custom search form in it.
2) It's the WordPress built-in search.
Best regards
Matthias
Thanks for the details , I assume you are displaying the post view's shortcode [wpv-view ... ] insider single page content.
I have test it, and I can see the problem as you mentioned above:
after the initial indexing the content of my snippets view isn’t indexed at all. But if I open the page where I use the views shortcode in the editor and just hit „Update“, the snippets content get’s indexed and then can be found in frontend search.
Then I have tried with a simple custom shortcode as you mentioned above, for example:
1) Add below codes in to theme file "functions.php":
add_shortcode('my-shortcode', function($atts, $content){
return '54321';
});
It will create a custom shortcode [my-shortcode], and output string: 54321
2) put the shortcode [my-shortcode] into single page content, I see the same problem:
the shortcode [my-shortcode] content get’s indexed only you update that page.
You can test it in your website:
1) put the php codes into your theme files
2) Put the shortcode [my-shortcode] into single page content,update the page
it get indexed, and you can search in wordpress built-in search box with keyword "54321", you will get the page in search result.
3) edit the php codes from:
return '54321';
To:
return '12345';
4) Search keyword: 12345 again, there isn't any result.
So it is a problem of Relevanssi plugin:
you need to update the page to get the shortcode content to be indexed, including Views shortcode [wpv-view].
But I do think it will be a great feature, you can add a feature request for it here:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/
Our developers will evaluate it.
Hello Luo,
This is not the actual problem. Of course, Relevanssi or SearchWP can only index any shortcode content, when a page is saved. The plugins can’t know about the change of shortcode content when they are only triggered after post or page updates. But this „problem“ can be solved with a daily re-indexing via cron job.
The problem I’m talking about is:
When there is no search index and you index the complete website for the first time, it seems that all shortcodes aren’t expanded and indexed properly. Only after manual updates of every page the shortcode contents are indexed properly. I talked to Relevenssi and SearchWP and they told me, the index function for the automatic indexing and the manual indexing (saving a page) is the same.
If you like, I can send you a clone of my test site.
Best regards
Matthias
I have tested it in my localhost, with a fresh wordpress installation + the latest version of Toolset plugins + Relevenssi plugin, there isn't the same problem as you mentioned above:
Only after manual updates of every page the Views shortcode [wpv-view] contents are indexed properly.
Please check these:
1) In case it is a compatibility problem, please deactivate other plugins, and switch to wordpress default theme 2019, and test again
2) Also check if there is any PHP errors in your website.
3) If the problem still persists, please provide database dump file(ZIP file) of your website, also point out the problem page URL and view URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/
Hello Luo,
1) I did.
2) No errors.
3) I will check this.
Some new details: Mikko from Relevanssi helped my to find out the following:
After the overall indexing the shortcode content definitely isn't indexed. I can check this with the feature "How Relevanssi sees this post" in the post editor. The indexed content is only "items". After saving the page one time and checking again, the content contains the complete shortcode content. See the screenshots.
Is this enough to investigate further or do you still need a clone of my test site?
Matthias
Please provide the duplicator package in below private message box:
https://toolset.com/faq/provide-supporters-copy-site/
Also point out the problem page URL, and which keywords you search in the wordpress built-in search box.
Thanks for the details, I am downloading the files, will update here if there is anything found
Here are what I found:
I can install the duplicator package in my localhost, here are detail steps, please correct me if there is anything missing.
1) Goto home page, search keyword "wopbabaloobopwopbamboo", I see result: Nothing Found
2) Edit page "My second page", click button "Publish", repeat step 1), I see search result:
- My second page
I understand this is the problem you mentioned above, but how the problem occurs? I need detail steps.
3) Then I create another page: "My third page", assign it with term "page-2"
copy/paste page content from "My second page" to the new page "My third page", click button "Publish", repeat step 1), I can see two items in the search result:
- My second page
- My third page
So views result does be indexed when I save the page "My third page" at the first time, can you confirm it in your website?
4) Then I have tried another cases:
a) Duplicate the post view "Related Snippets" into a new post view "Related Snippets 2"
b) Create new page "my fourth page", assign it with term "page-2", with same page content, but new post view's shortcode:
[wpv-view name="related-snippets-2"]
click button "Publish"
repeat step 1), I can see three items in the search result:
- My second page
- My third page
- My fourth page
So as I understand, you will need to "Publish" the page to get shortcodes content to be indexed by Relevanssi plugin.
Hi Luo
that's all correct!
Now try this: wipe the index by clicking "Build the index" in the relevanssi settings. And then go to te frontend and search. Wrong results: all pages are listed for all keywords.
Matthias
Thanks for the details, I can see the same problem, I am doing more tests in my localhost, will update here if there is other found.
I can duplicate the same problem in my localhost with a fresh wordpress installation, and have escalated this thread, will update here if there is anything news.
Thanks for the update, Luo! I'm looking forward to further news.
It has been escalated to our 2nd tier supporters, I will keep on updating here if there is anything news.