Support » Fixing WordPress » Create HTML file with get_archives()

  • 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:
    $file = ‘recent-headers.html’;
    $data = get_archives(‘postbypost’,’5′,’html’);
    $fp = fopen($file, “w”);
    fwrite($fp, $data);
    echo ($data);
    but it directs the output only to the screen — the created file contains no headers info (only some initial HTML headers).

Viewing 3 replies - 1 through 3 (of 3 total)
  • do u need a page with all the post links?
    in that case u need to replace the loop with the get_archive() function 🙂

    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….

    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Create HTML file with get_archives()’ is closed to new replies.