Clearing Content

This is the right place to report general bugs, make suggestions or ask for help.
Post Reply
User avatar
WineMan
Posts: 140
Joined: Tue Sep 01, 2020 5:03 pm

Clearing Content

Post by WineMan » Fri May 22, 2026 1:15 am

I have been "testing" version 1.5.1 of FlatPress and I am now ready to start the blog. What do I need to delete, edit or change to remove all content that I have been using to "test" my blog. I have looked in the wiki and can't seem to find anything that will guide me through this.

eagleman
Posts: 250
Joined: Sat Mar 02, 2019 12:10 pm

Re: Clearing Content

Post by eagleman » Tue Jun 09, 2026 8:47 am

You have to delete the welcome post, every post created by you to test your blog, the setup folder and setup php file into the main root of your blog.

User avatar
WineMan
Posts: 140
Joined: Tue Sep 01, 2020 5:03 pm

Re: Clearing Content

Post by WineMan » Tue Jun 09, 2026 5:55 pm

With the help of AI, the code listed below will delete all test articles and comments.

Make a copy of the fp-content folder, place this code in the root folder of the application and run it from a browser. You might need to re-index the application if there are remnants left over. Worked for me anyway. Here is the code.

Code: Select all

<?php
/**
 * FlatPress Test Data Wiper
 * Place this in your FlatPress root directory. 
 * DELETE THIS FILE AS SOON AS YOU ARE DONE.
 */

// Simple security check: Uncomment the line below and set a password if running on a live server
// if ($_GET['auth'] !== 'mysecret') die('Unauthorized.');

define('FP_CONTENT_DIR', __DIR__ . '/fp-content');

function delete_folder_contents($dir) {
    if (!is_dir($dir)) return;

    $files = new RecursiveIteratorIterator(
        new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS),
        RecursiveIteratorIterator::CHILD_FIRST
    );

    foreach ($files as $fileinfo) {
        $todo = ($fileinfo->isDir() ? 'rmdir' : 'unlink');
        $todo($fileinfo->getRealPath());
    }
}

echo "<h2>FlatPress Reset Script</h2>";

// 1. Clear Posts
$postsDir = FP_CONTENT_DIR . '/content';
if (is_dir($postsDir)) {
    delete_folder_contents($postsDir);
    echo "✔️ All articles deleted.<br>";
}

// 2. Clear Comments
$commentsDir = FP_CONTENT_DIR . '/comment';
if (is_dir($commentsDir)) {
    delete_folder_contents($commentsDir);
    echo "✔️ All comments deleted.<br>";
}

// 3. Clear Cache (Highly recommended so FlatPress notices the changes immediately)
$cacheDir = FP_CONTENT_DIR . '/cache';
if (is_dir($cacheDir)) {
    delete_folder_contents($cacheDir);
    echo "✔️ Cache cleared.<br>";
}

echo "<br><strong>Done! Your configuration, themes, and plugins are untouched.</strong>";

User avatar
WineMan
Posts: 140
Joined: Tue Sep 01, 2020 5:03 pm

Re: Clearing Content

Post by WineMan » Wed Jun 10, 2026 3:04 pm

In the event AI generated code is not allowed, just disregard the post and accept my apology for not checking to see if it is allowed.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests