WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] PHP Include/Require Issue (7 posts)

  1. cardboardbear
    Member
    Posted 7 years ago #

    I'd like to display my blogroll and my most recent blog entries on static pages on my site that I am not creating through WordPress. My original intention was to PHP include/require a template file that displays this information, but I'm getting the following error:

    Fatal error: Call to undefined function: get_links() in ***DIRECTORY*** on line 10

    Obviously this function isn't recognized on non-WordPress pages. How else can I do this. Because WordPress files are dynamic I tried to include the template file, but is there a way for me to include a Page?

    All suggestions are much appreciated.

  2. ccoupe
    Member
    Posted 7 years ago #

    WordPress only displays or manipulates what is in it's database and a very narrow set of files in the WP tree. Integrating things that aren't in the file system tree (another site) is a security issue so it's not done easily. Not that it can't be done with enough sweat and php.

    It very much depends on your site and page layout as too how much sweat.

  3. whooami
    Member
    Posted 7 years ago #

    Integrating things that aren't in the file system tree (another site) is a security issue so it's not done easily. Not that it can't be done with enough sweat and php.

    meh.

    @ cardboardbear,
    What you want to do can be done a few different ways.

    The simplest: you can use ANY wordpress function on any other php page by using a standard include to wp-blog-header.php at the top of the file you want to use the WP function on.

    Like so:
    // make sure the path below is correct
    <?php require('./wp-blog-header.php');?>
    // make sure the path above is correct

    your normal page stuff ....

    // start of get_links example below

    <?php get_links(category, 'before', 'after',
    'between', show_images, 'order',
    show_description,show_rating, limit,
    show_updated, echo); ?>

    .. some more of your page stuff...

    ---------------

    To reiterate, that include allows you to use ANY function, even a function which includes another file for instance.

  4. cardboardbear
    Member
    Posted 7 years ago #

    Awesome! That worked perfectly. Thanks!

  5. whooami
    Member
    Posted 7 years ago #

    you're welcome :)

  6. rcpkrc
    Member
    Posted 6 years ago #

    very good. nice information.

  7. oneppo
    Member
    Posted 6 years ago #

    I don't understand this, but I'm still a novice. I'm trying to get a php events calendar to load on an events page. All of my pages have the same header and side columns, only the content changes. How would I go about including a php-include code without it showing up as code?

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic