Saltar navegación

[Esperando confirmación del usuario] Split: Add a link to a relationship form – change the placeholder "search for a post" on relationship form

This support ticket is created hace 3 días, 14 horas. 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Zona horaria del colaborador: Asia/Kolkata (GMT+05:30)

Este tema contiene 8 respuestas, tiene 0 mensajes.

Última actualización por Minesh hace 2 días, 17 horas.

Asistido por: Minesh.

Autor
Mensajes
#2818246

Hi Dinesh,

Thanks a lot ! it's exactly what I wanted.

2 last questions:
- how can I retrieve the movie name in order to write it in a h3 tag ?
- is there any possibility to replace the placeholder "search for a post" by a custom text ?

#2818249

Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

To translate "search for a post" text on relationship form you will have to add the following hook to your theme's functions.php file at bottom:

add_filter( 'gettext', function( $translated_text, $text, $domain ) {
  
    if($text == 'Search for a post' && $domain == 'wp-cred'){
      $translated_text = "your text";
    }
    
    return $translated_text;
}, 10, 3 );

- Please replace "your text" with your original text.

#2818250

is there a way to have a rule for the "crew member" post search and other for other post-type ?

#2818252

Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

What you mean - you mean, you want to display different text on different page?

#2818253

In this form the post we are looking for is a "crew member". For another relationship form it could be a "movie" and the it should be "search for a movie" instead of "search for a crew member" instead of "search for a post"...

#2818254

Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

all those forms are added on different page right? if yes:

You can use the page ID to differentiate it.

For example:


add_filter( 'gettext', function( $translated_text, $text, $domain ) {
   global $post;

   if($post->ID == 99999 ) {
    if($text == 'Search for a post' && $domain == 'wp-cred'){
      $translated_text = "your text";
    }
   }

   if($post->ID == 88888) {
    if($text == 'Search for a post' && $domain == 'wp-cred'){
      $translated_text = "your text";
    }
   }
     
    return $translated_text;
}, 10, 3 );

Where:
- you can change the post ID 99999 and 88888 accordingly to target your text.

#2818259

unfortunately it does not seem to work.

#2818367

Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Have you replaced the target post ID with 99999 and 88888 with your original post ID where you added your form.

Can you please share details on what link what form you have and what text you want to display and send me admin access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2818391

Minesh
Colaborador

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Ok I've another way, I've added the following code to your relationship form's custom JS editor:

jQuery(document).ready(function($) {
    var classes = $('body').attr('class');
    
     
    var match = classes.match(/page-id-(\d+)/);

    if (match && match[1]) {
        var pageId = match[1];
        

        if (pageId == 12120) {
             $(".toolset_select2-selection__placeholder").text("Crew Member");
        }
    }
});

You can use the same code and add it to your other relationship forms and change the text and pageId value accordingly.