WordPress.org

Ready to get started?Download WordPress

Forums

Can I post to multiple templates from Write/Edit? (3 posts)

  1. Anonymous
    Unregistered
    Posted 9 years ago #

    Howdy, folks. I'm new to WordPress; you should be proud of the fruits of your labor.
    I'm attempting to use WordPress for a CMS (not a blog), and your descriptions seem to support WordPress as a publishing system rather than a blogging tool.
    I would like to be able to Write/Edit to a handful of templates but can't seem to figure out how to make this happen. From the Write/Edit pages there is no option to point to a page other than index.php.
    Help?

  2. Root
    Member
    Posted 9 years ago #

    WordPress only has one *page* index. It is driven by php and mysql.

  3. demuretwilight
    Member
    Posted 9 years ago #

    You can skip wordpress' built-in template support for pages if you want. Then you can have as many pages as you want, all with different formatting, each able to display any content (posts, etc) from your site. For example, you could have a home page that is like a usual wordpress home page, with a bunch of your newest posts on it (index.php). then you could have another page that also has these same posts on them, but with completely different formatting. or you could have two pages, each that displays the newest post, each with different formatting.

    You do this all by using pages other than (or in addition to) the index.php file (the one in the wordpress root directory, not the one from a template) for the stuff you want to display. The default wordpress index.php is the following:

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

    take out line 3:

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

    At this point if you view this page in a browser, you will get just a white page with no content. Now you can just add whatever you want, using regular html, php, css, etc., along with the wordpress-specific php functions to display your wordpress posts/content (eg. the loop and template tags--see http://codex.wordpress.org/Template_Tags).

    Note that you can add more pages, each with whatever content you want (or all with the same content, as discribed above--for example, you could post the same post to 5 different 'templates' using 5 different such files. all you have to do is make sure that at the beginning of these files, you include the code

    <?php
    require('./wp-blog-header.php'); /*change to point to where ever your wp-blog-header.php file is */
    ?>

    for an example of this in action, see http://www.spontaneousfun.com. The first page that comes up has the newest posts in it, which are pulled from wordpress and put into that format; but this is only one part of the page. if you click on the link 'read more' it takes you to another page with the same content as on the first page, but with different formatting; here the wordpress content is the main content.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.