Embed Drupal node form anywhere

Simple 1 line of code to embed a Drupal node form anywhere in your site although I would recommend doing it the Drupal way which is creating a custom module for this.

print drupal_render(node_add('NODE_TYPE'));

Where NODE_TYPE is your content type (machine name).

If the code above returns an error that says the function node_add() is undefined, add the following code before it.

if (!function_exists('node_add')) {
  module_load_include('inc', 'node', 'node.pages');
}

9 comments for 'Embed Drupal node form anywhere'

Booboo's picture

You are the best and this is the best tip I have seen on this subject, clear and simple but Incredible efficiency

octern's picture

This is a great tip! I would have burned a lot of time trying to come up with a much less elegant solution.

Add new comment