Skip Navigation

[Resolved] Changing the “No results found” text in a relationship field

This thread is resolved. Here is a description of the problem and solution.

Problem:

I am trying to insert custom text instead of the "No results found" in a relationship search field.

Solution:

You can override it with WP filter hook gettext, for example:

https://toolset.com/forums/topic/changing-the-no-results-found-text-in-a-relationship-field/#post-2102693

Relevant Documentation:

https://developer.wordpress.org/reference/hooks/gettext/

This support ticket is created 2 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by pascalS 2 years, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#2097035
no-results.png

Tell us what you are trying to do?
I am trying to insert custom text instead of the "No results found" in a relationship search field. In the attached image I am looking for a Director to attach to a film (called a Flix on the site).

I have set-up the Flix to Director relationship so that when I try and add a director it gives me a list of pre-populated directors.

However I want to give people the option of adding a director to the site if they can't find the one they need.

Currently the link to add a new director is under the Director field: "Can't find your director? Add a director"

I would like to show this text within the search instead of "No results found"

Is there any documentation that you are following?
No

Is there a similar example that we can see?
No

What is the link to your site?
hidden link

#2097571

Hello,

The text "No results found" is defined in Toolset Blocks/Views plugin file:
plugins\toolset-blocks\vendor\toolset\toolset-common\inc\toolset.assets.manager.class.php
line 749:

'noResults' => __( 'No results found', 'wpv-views' ),

You can override it with WP filter hook gettext, see WP document:
https://developer.wordpress.org/reference/hooks/gettext/

#2102297

Hi,

Do you think you could provide me with the full required code that I need to add to my functions.php
I'm not a coder and am worried that I am going to break some thing 🙁

Thanks
James

#2102693

For example:

add_filter( 'gettext', 'my_translate_text', 10, 3 );
function my_translate_text( $translated_text, $untranslated_text, $domain ) {
    if ( $domain == 'wpv-views' && $untranslated_text == 'No results found') {
        $translated_text = "Can't find your director? Add a director";
    }
	return $translated_text;
}
#2103023

My issue is resolved now.
Thanks so much! It's working perfectly. Really appreciate helping a "non-coder" 😉

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.