• Hi,
    I’m new to WordPress and PHP.
    We have a requirement to write the categories to a file, called, say , menu.xml
    I assume a write a php page to call a list_cats type function, then write the output to a file ?
    How do I do the last bit ?
    Thanks
    Dave

Viewing 3 replies - 1 through 3 (of 3 total)
  • Dave,
    Might I suggest that you visit the WP channel on IRC if you haven’t already? The locals there might be able to help you out!

    This is a bit of code I found somewhere for just opening and writing a file. You might need to create menu.xml with the right permissions first.
    $filename = '/server/path/to/menu.xml';
    if (is_writable($filename)) {
    if (!$handle = fopen($filename, 'w')) {
    echo "Cannot open file ($filename)";
    exit;
    }
    } else {
    echo "The file $filename is not writable";
    }
    $somecontent = 'blahblahblah';
    fwrite($handle, $somecontent);
    fclose($handle);

    Thread Starter daveprout

    (@daveprout)

    Excellent, that works for me.
    Thanks
    Dave

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Writing Categories to a file’ is closed to new replies.