WordPress.org

Ready to get started?Download WordPress

Forums

Create HTML file with get_archives() (4 posts)

  1. wpuser
    Member
    Posted 9 years ago #

    Dear Friends:
    Your help file for get_archives() function tells me that it "Displays a list of archives". However I need to redirect it HTML file with. I tried the code:
    <?php
    require('wp-blog-header.php');
    $file = 'recent-headers.html';
    $data = get_archives('postbypost','5','html');
    $fp = fopen($file, "w");
    fwrite($fp, $data);
    fclose($fp);
    echo ($data);
    ?>
    but it directs the output only to the screen -- the created file contains no headers info (only some initial HTML headers).

  2. OperaManiac
    Member
    Posted 9 years ago #

    do u need a page with all the post links?
    in that case u need to replace the loop with the get_archive() function :)

  3. TechGnome
    Moderator
    Posted 9 years ago #

    Right it "Displays" the list, doesn't "Return" the list, big diff and a point of annoyance for some. But at any rate, Sushbh is right. In order to get the type of file you are getting ,take a copy of the index.php file, rename it to, say archive.php, open it up to edit it, find the "WP Loop" (that's the part that reads "for each" blah, blah, blah....) then find the end of the loop (will be after the "Sorry not posts matched....") and cut it all out. Then replace it with <?php get)archives(); ?> Save it. Then in your index.php, add an item to your menu that links to archive.php....
    TG

  4. wpuser
    Member
    Posted 9 years ago #

    Thank you for feedback.
    My main related problem (not mentioned here) was caused by the fact that my main page is in ASP so I can't directly call PHP from it. After some Internet search I actually tried a 2-step solution that works allowing me to use output of get_archives() function in ASP page. I posted details of it in another post. If anybody interested, I can repost it here.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.