Support » Fixing WordPress » Creating new non wordpress pages with template

  • Resolved xpressprints

    (@xpressprints)


    Greetings. Sorry for the vague topic title, but I didn’t know how to word it shortly. I’ve searched all over for this, and I know that there’s an easy way to do this, but I haven’t been able to make sense of it all.

    I want to be able to create new web pages (not wordpress pages) that use the same theme (header, footer, and sidebar) that the rest of my blog site is using. Here’s an example of a site that’s doing what I’d like to do: http://teo.esuper.ro/

    as you click on the different links in the header, you’ll notice in the address bar that the .php pages are named accordingly – making these web pages, and not wordpress pages.

    I need the ease of adding my own html and php code to these separate web pages. Can someone please help me in achieving this? Thanks in advanced, and I hope I was clear in explaining.

Viewing 15 replies - 1 through 15 (of 16 total)
  • I didn’t see anything on that site that wasn’t WP generated, although I admit not looking very hard.

    You probably want WordPress static pages: http://codex.wordpress.org/Pages

    Static pages live outside your regular blog entries. Every page can have its own template if you want, and you can put all of the HTML and PHP code you want in the template. Then you just apply it to the page. The page itself need not have any content. It can be completely blank with all of the content in the template. Or you can write whatever you need in the page entry and combine it with your own code. Or whatever you want.

    Thread Starter xpressprints

    (@xpressprints)

    I’m not sure that this is what I’m looking for… But I don’t want to jump the gun and say that it’s not. I read this, twice to be exact, but I’m not quite following. How do I go about creating a static page? Where is the file actually located – on my server or in the database? Thanks for your help.

    xpressprints,

    All of the pages that are internal to my own site are pages I created independent of wordpress.

    what you want to do is very easy to accomplish.

    If you intended to include ANY wordpress code in the .php files you need to have this at the top of the pages:

    <?php
    /* Don't remove this line. */
    require('PATH TO/wp-blog-header.php');
    ?>

    Edit that PATH_TO, accordingly.

    What I personally do is simply copy the content right out of my theme files and then edit out, put back in.. what I want, dont want.

    The end result for me, has been wonderful

    < nods > I like to keep everything inside WordPress. No reason, really – I just do. My site needed several types of pages that have a different look, but where I have multiple pages of each type. So I just did what I outlined above: I created a page template that holds my content, and then I assigned it in some cases to a blank WP page and in some cases to a WP page where I included content. It works for me because I can create a bunch of pages with the same look and feel very easily.

    But in looking at the link that xpressprints provided, it appeared to me that the site was just using standard WP pages without doing anything fancy at all. I think the addresses in the nav bar have the format http://example-site.com/page-slug

    I’m somewhat sneaky though, I’ve followed suit with using includes for my header, sidebar, and footer.. so I copy and paste alot less code than one might think. Those files, that I include are also uniquely named, and arent included via WordPress, so they aren’t accessible to snoopers or wanna-be hacks.

    I essentially have this:

    <?php
    /* Don't remove this line. */
    require('./wp-blog-header.php');
    ?>
    my header stuff ...
    <;?php wp_head();>'
    <an include for my normal header image>
    .. come content...
    <an include for my footer>

    I toyed with putting all the header stuff inside one lone file but since my meta tags change, meh.

    I do this for my sidebar as well.

    I realize this is normal for a lot of themes, but then I have seen alot of themes that dont do this — and I so like the fact that I dont use standard, expected wordpress file names.

    That’s a good point.

    Thread Starter xpressprints

    (@xpressprints)

    wowsers, did i forget to mention that i’m new to css and php? I tried doing what whooami suggested but I ended up with a bunch of errors. which file should I be using to pull code from? thanks guys for you patience.

    ok, heres what you have to keep in mind —

    lets say, your wordpress install is in the root of your website, by that I mean, that you do not have it installed into its own directory.

    to use ANY wordpress code in a file you create, you must include one singular wordpress file, wp-blog-header.php.

    Given my example above, that file, wp-blog-header.php, would be in the root of your website.

    Follow so far?

    So .. lets say you want to put another php file in the root of your wordpress directory..

    the you would include wp-blog-header.php like so:

    <?php
    /* Don't remove this line. */
    require('./wp-blog-header.php');
    ?>

    the dot that you see in this line: ./wp-blog-header.php

    means that the file is in the same directory.

    Lets say you wanted to put your new php file in a directory underneath your wordpress install, maybe like so:

    myfiles/mynewfile.php

    to include ./wp-blog-header.php you would do this:

    <?php
    /* Don't remove this line. */
    require('../wp-blog-header.php');
    ?>

    the TWO dots that you see in this line: ../wp-blog-header.php

    means that wp-blog-header.php is in the directory above myfiles/

    Follow?

    One dot == ./ == current directory
    Two dots == ../ == directory above

    The simplest thing to do, is to create a php file, and work on JUST getting the path to wp-blog-header.php correct. Until youve done that,you will see errors on the page in your browser. Once you dont get any errors, youre good to go.

    Thread Starter xpressprints

    (@xpressprints)

    OK, thanks a lot for the break down. I did this, but the header didn’t show up. I tried adding in the footer, and that worked, but it was all text. What’s the next step?

    Thread Starter xpressprints

    (@xpressprints)

    also, here’s all the code from the index file:

    <?php
    /* Short and sweet */
    define('WP_USE_THEMES', true);
    require('./wp-blog-header.php');
    ?>

    thats the index.php from the root of your site — the root of your site is where wp-config.php is. Leave that file alone.

    The ONLY index.php you EVER want to mess with is the one inside whatever theme you are trying to edit.

    Thread Starter xpressprints

    (@xpressprints)

    ok, that was a lot easier than I thought! here’s my final code for those that may be having the same issues…

    <?php
    /* Don't remove this line. */
    require('./wp-blog-header.php');
    ?>
    
    <?php get_header(); ?>
    
    	<div class="main">		
    
    		<div class="content">
    
    this is where my stuff goes...
    
    		</div>
    
    			<?php get_sidebar(); ?>
    		<div class="clearer"><span></span></div>
    
    	</div>
    <?php get_footer(); ?>
    
    </div>

    thanks a ton to everyone that helped!

    Hehe! This is exactly what I was looking for. I want to create an image gallery without all of the pages showing up on the side bar. So, I started experimenting with the code. However, the side bar appears under whatever content I add. Is there a way around this?

    timelapse, this is just a guess without knowing what theme you are using and what you are doing exactly, but the content div is probably too big for the sidebar to fit next to it.

    blakewatson

    (@blakewatson)

    This is the same thing I want to do, but including wp-blog-header.php breaks osCommerce.

    I’m trying to put the wordpress header above the osCommerce (Netfirms) stuff. When i used static html, it was fine. simply including wp-blog-header.php causes an error.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Creating new non wordpress pages with template’ is closed to new replies.