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

Placeholder Image
Visual Composer Post Grid Problem

WPBakery Visual Composer Post Grid is compatible with WP Fastest Cache although it is not compatible with any other cache…

Clear the Cache by Calling the Function Hook
Clear the Cache by Calling the Function Hook

You can use hooks to clear cache at specific points in the execution of the code. By strategically placing cache…

Placeholder Image
Cloudflare Enable Browser Cache

You can enable Leverage Browser Caching on the settings page of WP Fastest Cache but if you are using Cloudflare,…

Ready to get started?

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