Relevanssi used the_title() before, but that was problematic: it made the highlights appear in navigation menus, recent post widgets and so on. That’s why Relevanssi moved to a custom function.
If you use a theme that gets updates, any template modifications should be done in a child theme. That way they won’t be overwritten by theme updates.
That’s right, we need a function that sets the user directly from the plugin settings. The problem is (as I told you) that every time a new version of the theme is released, it is necessary to modify the code. A quick setup in the plugin is ideal. In my themes I can’t do the change in the child theme, I have to do it in the original. Not all themes are created equal.
- This reply was modified 1 hour, 7 minutes ago by steve92.
Child themes are a basic WordPress feature and the standard solution for this specific issue, so I don’t think it’s a big stretch to rely on that. If it doesn’t work for you, then you can a) not use title highlights (it’s not a critical feature anyway), b) take the trouble of modifying the theme after every update, c) ask the theme developer to build in the Relevanssi compatibility =D or d) create some solution that uses the the_title filter hook to add in the title highlights and accept that the highlights will appear everywhere there’s a title.
The articles I write sometimes contain the item only in the title and not in the article. Is it so hard for you to put this function in the plugin?
Each user and each theme has their own situations.
E.g. i use donovan theme, the code is in the file /template-parts/content-excerpt.php #18 if i put the modified function in the child file it shows error.
- This reply was modified 47 minutes ago by steve92.
As I said, Relevanssi used to add the highlights with the the_title() function just as you want, but it led to many problems in the shape of highlights appearing in places where they shouldn’t. As the_title() is used to display all titles everywhere on the site, adding the highlights to the function output adds them everywhere. That isn’t acceptable behaviour from a plugin.
The solution as is elegant and perfectly functional. I understand themes are different, but I can’t support every unusual theme there is. I’ll have to draw the line somewhere, and the line is to stick with the conventional WordPress standards.
Also, the Donovan theme does support child themes: the theme developer suggests using one in the theme documentation. You should be able to create a child theme, copy the template part in the child theme and replace the_title() with relevanssi_the_title(). If you have problems with creating the child theme, perhaps the theme support can help you?
To get the highlights in the titles – Relevanssi has no other mechanism to add the highlights to the titles when using the_title(). I have no idea where the highlights are coming from in your case.
