WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] contact form integration (3 posts)

  1. Doodlebee
    Member
    Posted 7 years ago #

    I had a quick question - I wanted to update the contact form on my site and make it more "WordPress Friendly". Currently, you'd have to basically make the form based on the stuff you do in WordPress - I can't call in the wordpres sheader, sidebar, footer and such and have my contact form stuff in the middle where "index" would usually be. But I would like to do that so that, anytime I update the sidebar or anything, the contact form would be updated.

    My contact form uses 3 pages: an index.php file (which contains all the form checks and stuff), and the contact.html and accept.html pages, which - for the most part - holds the layout of the pages. There's a little PHP in there, but not much.

    Now, because the index.php file holds all of the script info for checking and stuff, it seems I can't just add an include in the HTML file to call in the header, sidebar and such from WordPress. I think it has something to do with putting the PHP include in the HTML file, and then the HTML file is included in the index.php file. (Does that make sense?)

    Would anyone know how to edit/alter the index.php file to call in the sidebars and such, while still keeping my contact form content? I can't seem to find the proper code/way to insert the WordPress stuff into it.

    If you need to see code:

    the index.php file
    the simple.html file

    Anyone have any ideas for me? Thanks :)

  2. Jon Bourne
    Member
    Posted 7 years ago #

    This is actually pretty easy. Just include wp_config.php (in the root of your WordPress installation) into each page. This will give you access to all of your WordPress functions. Then, where you want the header, call get_header(), and where you want the sidebar, call get_sidebar(), and where you want the footer, call get_footer().

    It is best to use an absolute path to config.php rather than relative, ie. use include('/home/your_user/public_html/wordpress_directory/wp-config.php') instead of include('../wp-config.php').

  3. Doodlebee
    Member
    Posted 7 years ago #

    Rock on! *thank you so much!*

    Turns out I only had to put it in the index.php file - not all of them - because they're all called in from the index.php file. But cool - worked like a charm - thanks so much!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.