Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress From Bootstrap to WordPress Add Bootstrap Components to WordPress Theme How to Add Bootstrap Modal Windows to Your WordPress Theme

Sanjeev Veloo
Sanjeev Veloo
4,713 Points

Latest Ninja Forms does now show PHP code? Only shortcode?

Hey guys

The latest ninja forms plugin doesn't seem to show php code anymore, just the shortcode for using the form? What alternative route should i use?

5 Answers

Samuel Glister
Samuel Glister
12,471 Points

Hi Sanjeev,

What is it you are trying to do with your form? Most of what you probably want to achieve can probably be done so with a shortcake.

If you want to add your form directly into the template file you can do so with this

<?php echo do_shortcode('[your-form-id]') ?>

I know this is an old topic but I found a way to make Ninja Forms work, you simply have to put:

<?php Ninja_Forms()->display( 1 ); ?>

(where 1 = the id of the form you want to use) into your code inside of the modal-body div. Full footer.php code below:

 <hr>

      <footer>
        <p>&copy; <?php bloginfo( 'name' ); ?> <?php echo date('Y'); ?></p>
      </footer>
    </div> <!-- /container -->

    <div class="modal fade" id="contactForm">
      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title">Contact Us</h4>
          </div>
          <div class="modal-body">

            <?php Ninja_Forms()->display( 1 ); ?>

          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
          </div>
        </div><!-- /.modal-content -->
      </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->

    <script src="../../assets/js/ie10-viewport-bug-workaround.js"></script>

    <?php wp_footer(); ?>

  </body>
</html>

Hopefully this helps someone coming to this lesson in the future!

An alternative route from Ninja is and you still want it to be free is WP Forms. Its pretty basic, but easy to make responsive. If you can afford it, I would use Gravity forms.

Bradley Maravalli
Bradley Maravalli
8,927 Points

My solution was to use the Contact Form 7 plugin and place the following code within the modal body class.

<?php echo do_shortcode( '[contact-form-7 id="95" title="Contact form 1"]' ); ?>

I've installed Contact Form and coppied the shortcode within the modal body class. But in order to it work properly, i've had to add this WP function: do_shortcode

<?php echo do_shortcode('[contact-form-7 id="155" title="Contact form 1"]'); ?>