Link Library and WP Search results
-
Hello,
I have a question about search results with WordPress search function. At the moment, I enabled finding of link-library-items.
On the one side, maybe someone including me help that. On the other side, the search results for all link-library-items shows only an empty content, which isn’t helpful. No one, execpt me, know that such search results are items from link-library which will be readable after a mouse click on the title. It looks like to be a bug of the website…
My question according to that. Why isn’t there a content on the search result for all link-library-items? Is it a problem in Link Library or something different with WordPress, Theme or similar?
Please for response.
The page I need help with: [log in to see the link]
-
The thing about WordPress search is that it displays the item title and content by default in results. If you had entered text in the full-page content field of the link editor, then you would see that content appear under the link name. That being said, the link title would also only point to a local page on the site and not to an external page.
To get links to appear better, you would need to modify your theme’s search results template and to put in code that would display things different when the item is of type link_library_links. That custom code could read all of the link’s meta fields and display data that is of interest to you.
I can work at providing an example of such a search template for one of the default WordPress themes if it would be helpful to you. I could even do it for a specific theme if it’s a free WP theme or if you provide the theme files.
Please consider donating to support this plugin’s development.
Thinking about your question a bit more, I may be able to change the way that search results are displays through filters in my own plugin code. I would need to switch out the item title link and to allow users to format what information gets populated in the content. I will work on this functionality in the next week or two and let you know if/when I get good results.
Thank you for your response and your offer to create an example.
At the moment I still use Suffusion (really old theme with some big updates from two other users and also by myself for small stuff). The original author stopped support.
I search for a new theme since several months. At the moment it looks like it will be the Responsive theme. I started to learn creating a child theme and integrated the small stuff from my old theme. I use the free Responsive theme 4.5.6 (there is also a PRO-Version).
I created a zip-archiv with theme and child-theme for download at https://blackseals.net/blog/sdm_downloads/responsive-theme-child-theme/edit: Oh, didn’t see your second post (I need to much time to answer ?? – special to use the send button). That is also a good way. It seems to me that is much better for all user. I will wait until your response.
I have just published a new version of Link Library that adds improvements to how search results are displayed.
There is a now a new tab under Global Options called ‘Global Search Results Layout’. In that tab, you will be able to do a few things:
– Define a content template for content to replace the excerpt section. You can use a number of placeholders (e.g. [link_description]) to choose what should appear
– You can decide if the item title link should use the link URL defined in Link Library
– You can define a prefix to appear in front of link item (e.g. “External Link: “)I have tested it with sample themes and it works fine. Please try it with your theme and see if it works well for you too. I may need to filter other fields if they are used in your theme search results. Please consider donating to support this plugin’s development.
Thank you for your fast integration. I will try and report. At the moment I’m ill, but already getting better.
Hello,
I updated to the latest version of Link Library. I changed the settings for ‘Global Search Results Layout’ similar to the ‘Single Item Layout’. With my old Suffusion Theme, nothing changed. It shows only the title.
Isn’t a big deal, because I’m going to change to annother Theme. However, I tried it on an internal WordPress installation. It don’t work too. I use now OceanWP Theme, because found strange problems with Responsive Theme.
I already wrote several emails to the developer of OceanWP. At the moment I wait for an answer of my latest email. There is also coming a new version for OceanWP. Maybe it will work with that.
According to “Please consider donating to support this plugin’s development”… I didn’t forgot. Waiting for next month and it isn’t a April Fool.
Which theme did you try in the internal WordPress installation? I’m using Twenty Twenty and I get I can see links and their description in the search results. I set my Global Search results simply to:
Description: [link_description]
Hello, thank you for your really fast response. I use the OceanWP Theme. I tried several content for the Global Search results, but nothing work. If I change to Twenty Twenty-One, it work.
According to my knowledge, it looks like, the OceanWP Theme get the content in a different way. Don’t know if it is possible to change that with a child-theme…
It looks like, it prefer normal posts. In that way not so much pages and nothing from custom post-types.I’m not a (theme) developer, but according to my search, the OceanWP Theme use ‘the_excerpt();’ function to get a content for the search. I tried several plugins for excerpt, but nothing helped.
The only helpful plugin extended only the search to find words in custom tables. I’m able to search in the “link_description”, but it will not showed in the search results (only the title).
Ah, I see what it might be. I was filtering for get_the_excerpt and not for the_excerpt. Could you try replacing the contents of the link-library.php file in the plugin’s directory with the following contents: https://gist.github.com/ylefebvre/e8e300bb9dbaa26d30d1ac9d2d6c9512
If that still does not work, would you be able to send me your theme’s code via e-mail to ylefebvre at gmail dot com? This would allow me to take a closer look at what they’re doing in there.
Looking forward to hearing back from you and thanks for your support!
I did that, but nothing changed. Email is on the way, but Gmail have a strange problem with ZIP-files: This message was blocked because its content presents a potential security issue. Therefore I try WeTransfer.
By the way, I found a problem with the latest Link Library 7.0 and OceanWP Theme if I want use the User Submission. In my case, I’m missing Link Category. I use “Drop-down List” and also tried “Multi-select”.
On my public website it is still working, so that is some strange troubles with OceanWP Theme or… I have recently revised the categories and now work with subcategories. Maybe that is the reason?
Hi Andy,
I just sent you a new zip file. Unzip these extra files in your oceanwp-child folder and you should be all set. Don’t delete the existing oceanwp-child files. Just add these ones over.
The problem was the way that your theme’s search template was written, as can be seen below:
<div class="search-entry-summary clr"<?php oceanwp_schema_markup( 'entry_content' ); ?>> <p> <?php // Display excerpt. if ( has_excerpt( $post->ID ) ) { the_excerpt(); } else { // Display custom excerpt. echo wp_trim_words( strip_shortcodes( $post->post_content ), $length ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } ?> </p> </div><!-- .search-entry-summary -->
Basically, the theme was looking to see if there was anything in the custom excerpt field of the post. If there is, then it renders the excerpt. If not, it goes to get the post_content directly without any filtering. This is not great for plugins like Link Library since there is no way to filter the has_excerpt function, and my post content filters are not getting called either.
To show others the solution that I put in place, here is the modified code for search results that I put in the child theme:
// Display excerpt. if ( has_excerpt( $post->ID ) || 'link_library_links' == get_post_type( $post->ID ) ) { the_excerpt(); } else { // Display custom excerpt. echo wp_trim_words( strip_shortcodes( $post->post_content ), $length ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped }
Basically, I only modified the if condition here to check if the post has a custom excerpt or if the post type is a link. This way, the_excerpt is called, which in turn called my filter and outputs the search content defined in my plugin.
For your question about link categories not appearing in the user form, could you start a new thread?
Thank you so much. It is working perfectly. Really strange decision from the theme developers… it seems to me, there are more plugins like Link Library which extend post types and includes an excerpt. I will try to write a message to them – maybe they are able to extend the theme for global using in such a case.
According to the problem, there is now a new thread for it.
It is really a strange decision to write the code as they did. Essentially, they re-wrote the the_excerpt function, but with no chance for a plugin developer to filter the data. When you call the_excerpt, it looks to see if there is a custom excerpt, then generates one from the post_content if there isn’t.
-
This reply was modified 3 years, 11 months ago by
Yannick Lefebvre.
-
This reply was modified 3 years, 11 months ago by
- The topic ‘Link Library and WP Search results’ is closed to new replies.