Skip to:
Content
Pages
Categories
Search
Top
Bottom

Add a “page” to my template

  • How would I go about adding a page with static informaiton to my template?

    I have the page ‘purchase.php’ and want to add it into my template. I thought I would just do an include, but then I realized I have nothing to include into.

    Then I thought I would just get header and get footer around my static info and link directly for it, but then the bb functions are being called correctly.

    What is the best way to include static information in the site in a manner where I can include a link to it?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    Here is a quick php for it(Use this method at your own risk), you need pretty permalink to use it.

    Save the following code in bbPress root folder as page.php

    <?php
    require_once('./bb-load.php');
    if (preg_match('/.*/page/(.*)/', $_SERVER['REQUEST_URI'], $matches)) {
    $file = bb_slug_sanitize($matches[1]) . '.php';
    if (file_exists(bb_get_active_theme_folder() . "/static/$file")) {
    bb_load_template("static/" . $file);
    exit(0);
    }
    }
    wp_redirect(bb_get_option('uri'));
    ?>

    Put your static pages in a new static folder under your template folder, they should looks like

    <?php bb_get_header(); ?>
    The static content here.
    <?php bb_get_footer(); ?>

    Then you can access a static file. For example, access test.php(bb-templates/yourtemplate/static/test.php) at http://yoursite.com/bbpress/page/test

    Remember: Use this method at your own risk


    ralev-dot-com
    Member

    @ralev-dot-com

    I’m using this method here: http://desbar.eu/

    check the ABOUT page, for example

    it works for me.

    Keep in mind there are a lot of ways to make a static page.

    1. The most simple is to create some about.php file.

    It should looks like livibetter says:

    <?php bb_get_header(); ?>

    The static content here.

    <?php bb_get_footer(); ?>

    2. put this about.php in the root directory ( e.g. – the URL should be something like youbbPressSite.com/about.php )

    3. Then call this URL from somewhere ( e.g. – put a link in the Header.php )

    that’s it.

    PS: I’ve just been curious about the method above (livibetter version) – that’s why I used it :) looks smoother at first site.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar