WordPress.org

Forums

using wordpress commands in my php template (4 posts)

  1. mike9393
    Member
    Posted 10 years ago #

    I'd need to combine wp into a different php template framework. So Is there a way to call for example sidebar.php file to work in some part of my page ?! Or fetch my posts to a html page?

  2. moshu
    Member
    Posted 10 years ago #

    You can make your .php files (not the html ones, though!) "WP aware" by putting at the top of the file - before anything else this:
    <?php
    require('./path-to-your-blog/wp-blog-header.php');
    ?>

    After that you can use all the WP functions in those pages.

  3. mike9393
    Member
    Posted 10 years ago #

    Fatal error: Call to undefined function: wp_get_archives() in

    hmmm I've tried everything I can. Does WP index file or wp-blog-index etc. have to be in the same folder or something? If I can't get this to work is there any "feed readers" which could insert my blog posts to my other php page and even the sidebar?

  4. moshu
    Member
    Posted 10 years ago #

    Where is the file you are trying to display archives on, and (relative to it) where is the blog?
    Probably it's a matter of wrong path you put in the codeline above.
    And just for the sake of clarity:
    there is no wp-blog-index file and I never mentioned any WP index file.
    If your whatever.php file is in the root of your site and WP is installed in a floder called "myblog" then the above code should be
    require('./myblog/wp-blog-header.php');
    If the whatever.php is in a folder under the root AND your WP install is in another folder under the root, then obviously the path will change:
    require('../myblog/wp-blog-header.php');
    Google for "relative path".

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags