Skip Navigation

[Resolved] Many to Many default no match/no results found message

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

Problem:

But in my many-to-many relationship forms, it says "No (cpt) can be associated to (post title)". This is confusing to the user. I would rather it say "no results found" like the other forms, or "does not match available selections" or something like that.

Solution:

You can customize that message with WP filter "gettext", for example:

https://toolset.com/forums/topic/many-to-many-default-no-match-no-results-found-message/#post-2355947

Relevant Documentation:

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

This support ticket is created 2 years, 7 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.

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 sarahK-2 2 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#2355581

I have many:many relationship forms.

In the one:many relationship forms, when a wrongly spelled or non-existent post is typed in it says "no results found".

But in my many:many relationship forms, it says "No (cpt) can be associated to (post title)". This is confusing to the user. I would rather it say "no results found" like the other forms, or "does not match available selections" or something like that.

I can't find where to make this change. Thanks in advance.

#2355947

Hello,

You can customize that message with WP filter "gettext", for example, add below codes into your theme file "functions.php":

add_filter( 'gettext', function( $translated_text, $untranslated_text, $domain ) {
    if ( 'wp-cred' == $domain && 'No %POST_TYPE_LABEL% can be associated to %OTHER_POST_TITLE%' == $untranslated_text ) {
        $translated_text = 'no results found';
    }
	return $translated_text;
}, 10, 3 );

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

#2356615

Thanks Luo, this worked great on a test site, but did not work on the actual site. Any ideas about what I might check/troubleshoot?

#2356733

There might be some cache issue in your website, if you are using some other cache plugins, please try to clear cache and test again.

#2358357

It was not a cache issue. It was a plugin conflict. Either way, all fixed, and thank you for your help.