skip to Main Content

I need to insert a shortcode [ajaxdomainchecker] into an existing html code.

I tried the following code but it shows error. Would you please let me know how to add the shortcode?

SyntaxError: Unexpected identifier:

<script>
    jQuery(document).ready(function(){
        var sessionName = '<?php echo do_shortcode("[ajaxdomainchecker]"); ?>';
        jQuery(" .acf-field-60po7a8eu9444 p.description").html(sessionName);
    });
</script>

SyntaxError: missing ) after argument list

jQuery(' .acf-field-60po7a8eu9444 p.description').html('<?php echo do_shortcode("[ajaxdomainchecker]"); ?>');

SyntaxError: Invalid or unexpected token

jQuery(" .acf-field-60po7a8eu9444 p.description").html("<?php echo do_shortcode('[ajaxdomainchecker]'); ?>");

SyntaxError: Unexpected token

jQuery('.acf-field-60f5d9a279544 p.description').html(<?php echo do_shortcode('[ajaxdomainchecker]'); ?>);

Existing code (created using acf/frontend):

<div class="acf-field acf-field-textarea acf-field-60po7a8eu9444 elementor-repeater-item-b95d154" data-name="rtype_selection_desc" data-type="textarea" data-key="field_60po7a8eu9444">
    <div class="acf-label">
        <label for="acf-field_60po7a8eu9444">Enter Info</label>
    </div>
    <div class="acf-input">
        <p class="description">Search and Enter Info</p>
        <!-- how to add the short code here? -->
        <textarea id="acf-field_60po7a8eu9444" name="acf[field_60po7a8eu9444]" rows="8"></textarea>
    </div>
</div>

2

Answers


  1. You have the right idea with the do_shortcode() command, but you can just put it right into your PHP file like so:

    <?php echo do_shortcode("[ajaxdomainchecker]"); ?>
    
    Login or Signup to reply.
  2. You can add the shortcode in your post where you enter the data in ACF input. And set your shortcode as a default value to that field.
    "Make a search and enter info" label as another ACF field that helps you change the text of the label whenever you want.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search