Home Forums Front-end Issues initialize js


initialize js

  • Hello,

    I tryed coding a front end user post, and so far everithing went well.
    However, i am stuck at initializing the JS, in order to make the conditional fields and map to work.

    Can somebody please tell me what code do i need to add, and where? This JS code is way over me, and i do not know how to work with it.

    Thank you for helping me!

  • Hi @viorelepuran

    If you’re using ACF 5 all you need to to for the necessary JS to load is to put this at the very top of the template file (above get_header())
    <?php acf_form_head(); ?>

  • Hello Jonathan and thank you for trying to help me out.

    I am using acf pro 5.0.8 and i did placed that code before the get_header.

    However,the form gets displayed,but several fields are not working properly,like the map or the logical fields.

    Please have a look at

  • I’m not able to access the domain you’ve linked?

  • And this is the code i am using on that page template :

    * Template Name: Vinde Moto
    <?php acf_form_head(); ?>
    <?php get_header(); ?>

    <div id=”page” class=”single”>

    <article class=”<?php mts_article_class(); ?>”>

    <div id=”content_box” >

    <div id=”primary”>
    <div id=”content” role=”main”>

    <?php /* The loop */ ?>
    <?php while ( have_posts() ) : the_post(); ?>

    <h1><?php the_title(); ?></h1>

    <?php acf_form(array(
    ‘post_id’ => ‘new_post’,
    ‘post_title’ => true,
    ‘new_post’ => array(
    ‘post_type’ => ‘moto’,
    ‘post_status’ => ‘publish’
    ‘return’ => ‘/anunt-publicat’,
    ‘updated_message’ => __(“Post updated”, ‘acf’),
    ‘submit_value’ => ‘Listeaza’
    )); ?>

    <?php endwhile; ?>

    </div><!– #content –>
    </div><!– #primary –>



    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

  • Would it help you if i grant you access to my admin area?

  • No there’s no need for that 🙂

    Your issue is actually not with ACF per se but rather that you have a JS error occurring early on the page resulting in all other JS not loading. Javascript is like PHP in the sense that if a fatal error occurs it stops all further rendering.

    This code

    jQuery.fn.exists = function(callback) {
      var args = [], 1);
      if (this.length) {, args);
      return this;

    causes this error:
    Uncaught TypeError: Cannot read property ‘call’ of undefined

    So it would seem like callback is undefined at that point in your javascript.

  • I will try to find andd remove that code, and then change the theme

    I`ll let you know how things go.

    Thank you for taking time to help me out.. you are awsome!

  • No worries mate! Let me know how it works out!

  • Oh and if you have any trouble finding the code snippet it’s at the very beginning of customscript.js found here:

  • You are right.

    I just edited that file, removed that code and now it runs perfectly!

    Thank you verry much for helping me out!

    And for everibody else who is reading this, i am using schema theme, and the error was in /wp-content/themes/schema/js/customscript.js == i just deleted the first 7 lines.

    Thank you again Jonathan!

  • No problem 🙂

    But be careful since the code probably was there for a reason so you might want to check that all other functionality of your site is working without it 🙂

    If not you might want to contact the theme author and notify them of the issue so that they can fix it in an update!

Viewing 13 posts - 1 through 13 (of 13 total)

The topic ‘initialize js’ is closed to new replies.