Create a Post Cache by ID Using the Function Hook

Create a Post Cache by ID Using the Function Hook

by admin

This function is designed for manually creating page caches.

By calling wpfc_create_post_cache_by_id with a specific post ID, you can create caches for both the page and its categories, along with the page’s tags.

The function takes a single parameter, $post_id, which is the unique identifier of the post you want to cache. By using the post ID, the function can identify and cache the post’s content, metadata, or any other data associated with it.

//it creates cache for post id 1923.
wpfc_create_post_cache_by_id(1923);

You can use the apply_filters() function to retrieve data. Here’s how you can use apply_filters to retrieve data.

$result = apply_filters('wpfc_create_post_cache_by_id', 1923);
print_r($result);

The above example will output:

Array
(
    [0] => Array
        (
            [url] => https://site.com/2022/12/26/indias-spiritual-city-that-sings/
            [success] => 1
        )

    [2] => Array
        (
            [url] => https://test.wpfc.ml/category/news/
            [success] => 1
        )

    [3] => Array
        (
            [url] => https://test.wpfc.ml/tag/city/
            [success] => 1
        )

    [5] => Array
        (
            [url] => https://test.wpfc.ml/tag/spiritual/
            [success] => 1
        )
)

Note: If the function is called from within a theme file, it returns false.

Related articles

How to Serve WebP Images on Nginx
How to Serve WebP Images on Nginx

After the images are optimized, they are served as webp on Apache servers automatically. However, this situation is not possible…

How to Change Default Permalink in WordPress
How to Change Default Permalink in WordPress

The default permalink structure might not always align with your website’s goals or SEO strategies. Changing the default permalink structure…

Placeholder Image
Admin Toolbar has disappeared

When WP Fastest Cache is enabled, the admin toolbar may disappear.

Ready to get started?

Purchase your first license and see why 1,500,000+ websites globally around the world trust us.