Forums

Create new php page: which INCLUDE and REQUIRE to do? (8 posts)

  1. golber
    Member
    Posted 3 years ago #

    Hi, I want to create a new php page to show some custom things. Before writing code in this page, which INCLUDE or REQUIRE i must to insert to use all wordpress funcions and classes?

  2. Michael Fields
    Theme Wrangler
    Posted 3 years ago #

    Something like this should work for you:

    <?php
    	require_once '/home/user/public_html/wp-config.php';
    	require_once '/home/user/public_html/wp-settings.php';
    	get_header();
    	// CUSTOM CONTENT GOES HERE
    	get_sidebar();
    	get_footer();
    ?>

    You will need to replace the /home/user/public_html/ part with the server path to your WordPress installation.

  3. whooami
    Member
    Posted 3 years ago #

    require_once '/home/user/public_html/wp-config.php';
    require_once '/home/user/public_html/wp-settings.php';

    Unnecessary.

    wp-blog-header.php takes care of both of those.

  4. Michael Fields
    Theme Wrangler
    Posted 3 years ago #

    Whooami,
    So, this would be a better solution:

    <?php
    	require_once '/home/user/public_html/wp-blog-header.php';
    	get_header();
    	# CUSTOM CONTENT GOES HERE
    	get_sidebar();
    	get_footer();
    ?>
  5. whooami
    Member
    Posted 3 years ago #

    This works:

    require('./wp-blog-header.php');

    wp-blog-header.php takes care of including everything necessary to use WP fucntions outside of WP.

    (adjusting the path, obviously)

  6. golber
    Member
    Posted 3 years ago #

    Thanks a lot.
    Tomorrow I'll try your code.
    Bye

  7. theminio
    Member
    Posted 3 years ago #

    Hello,
    it's my first post here!nice to meet u!

    So I had the same question, and I understand your answers.But i have a other question.
    I create a new page, for example page2.php I do all the thinks you say,ok with this.
    But how can I display the page to browser??

    I use permalinks to get post like site-url/month/day/category/post-title or for the pages site-url/page-title. How can display the page2.php which I was create?
    Is there any way to get it like site-url/pages/page2 ??

    Thank you.

  8. Dedalos
    Member
    Posted 3 years ago #

    Bad replies, no solution. This should be well documented in the codex, don't reply with crap...
    For me isn't working your code. waste time!

Topic Closed

This topic has been closed to new replies.

About this Topic