MailChimp for WordPress: Any way to display a form by identifying its name and not its identifier?

I want to call my form from my template, but I do not want to use identifiers (since my form will have different identifiers on different servers). Is there a way to call a form from my name and not its identifier?

EDIT: clarify in my template instead of calling the form, using, for example echo do_shortcode('[mc4wp_form id="7"]');(which will not work on another server, where the same form has a different identifier), I would name it by name, using a command of this type: display_mailchimp_form('android_user_signup');where "android_user_signup" is this is the name of my form. Thus, even if the same form has different identifiers on different servers, if its name is the same, the form will be successfully called.

+4
source share
1 answer

try redefining the short code using your own function, in your function find the identifier by the attribute that you passed as "name", then call the original function.

[updated at Shawn's request, here is a snippet of code]

<?php 
$post = get_page_by_title( 'title', OBJECT, 'mc4wp-form' );
if ( $post ) {
    $id = $post->ID;
    echo do_shortcode('[mc4wp_form id="$id"]');
}
?>
+2
source

Source: https://habr.com/ru/post/1669307/


All Articles