Title: wp_cache_set_salted
Published: February 24, 2026

---

# wp_cache_set_salted( string $cache_key, mixed $data, string $group, string|string[] $salt, int $expire ): bool

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_cache_set_salted/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_cache_set_salted/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_cache_set_salted/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_cache_set_salted/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_cache_set_salted/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_cache_set_salted/?output_format=md#wp--skip-link--target)

Stores salted data in the cache.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_cache_set_salted/?output_format=md#parameters)󠁿

 `$cache_key`stringrequired

The cache key under which to store the data.

`$data`mixedrequired

The data to be cached.

`$group`stringrequired

The cache group to which the data belongs.

`$salt`string|string[]required

The timestamp (or multiple timestamps if an array) indicating when the cache group(
s) were last updated.

`$expire`intoptional

When to expire the cache contents, in seconds.
 Default 0 (no expiration).

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_cache_set_salted/?output_format=md#return)󠁿

 bool True on success, false on failure.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_cache_set_salted/?output_format=md#source)󠁿

    ```php
    function wp_cache_set_salted( $cache_key, $data, $group, $salt, $expire = 0 ) {
    	$salt = is_array( $salt ) ? implode( ':', $salt ) : $salt;
    	return wp_cache_set(
    		$cache_key,
    		array(
    			'data' => $data,
    			'salt' => $salt,
    		),
    		$group,
    		$expire
    	);
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/cache-compat.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/cache-compat.php#L244)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/cache-compat.php#L244-L255)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_cache_set_salted/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_cache_set()](https://developer.wordpress.org/reference/functions/wp_cache_set/)`wp-includes/cache.php` |

Saves the data to the cache.

  |

| Used by | Description | 
| [_find_post_by_old_slug()](https://developer.wordpress.org/reference/functions/_find_post_by_old_slug/)`wp-includes/query.php` |

Find the post ID for redirecting an old slug.

  | 
| [_find_post_by_old_date()](https://developer.wordpress.org/reference/functions/_find_post_by_old_date/)`wp-includes/query.php` |

Find the post ID for redirecting an old date.

  | 
| [WP_Term_Query::get_terms()](https://developer.wordpress.org/reference/classes/wp_term_query/get_terms/)`wp-includes/class-wp-term-query.php` |

Retrieves the query results.

  | 
| [WP_Network_Query::get_networks()](https://developer.wordpress.org/reference/classes/wp_network_query/get_networks/)`wp-includes/class-wp-network-query.php` |

Gets a list of networks matching the query vars.

  | 
| [WP_Site_Query::get_sites()](https://developer.wordpress.org/reference/classes/wp_site_query/get_sites/)`wp-includes/class-wp-site-query.php` |

Retrieves a list of sites matching the query vars.

  | 
| [WP_Comment_Query::get_comments()](https://developer.wordpress.org/reference/classes/wp_comment_query/get_comments/)`wp-includes/class-wp-comment-query.php` |

Get a list of comments matching the query vars.

  | 
| [wp_get_archives()](https://developer.wordpress.org/reference/functions/wp_get_archives/)`wp-includes/general-template.php` |

Displays archive links based on type and format.

  | 
| [WP_Query::get_posts()](https://developer.wordpress.org/reference/classes/wp_query/get_posts/)`wp-includes/class-wp-query.php` |

Retrieves an array of posts based on query variables.

  | 
| [get_objects_in_term()](https://developer.wordpress.org/reference/functions/get_objects_in_term/)`wp-includes/taxonomy.php` |

Retrieves object IDs of valid taxonomy and term.

  | 
| [get_adjacent_post()](https://developer.wordpress.org/reference/functions/get_adjacent_post/)`wp-includes/link-template.php` |

Retrieves the adjacent post.

  | 
| [WP_User_Query::query()](https://developer.wordpress.org/reference/classes/wp_user_query/query/)`wp-includes/class-wp-user-query.php` |

Executes the query, with the current variables.

  | 
| [count_user_posts()](https://developer.wordpress.org/reference/functions/count_user_posts/)`wp-includes/user.php` |

Gets the number of posts a user has written.

  | 
| [count_many_users_posts()](https://developer.wordpress.org/reference/functions/count_many_users_posts/)`wp-includes/user.php` |

Gets the number of posts written by a list of users.

  | 
| [get_page_by_path()](https://developer.wordpress.org/reference/functions/get_page_by_path/)`wp-includes/post.php` |

Retrieves a page given its path.

  |

[Show 9 more](https://developer.wordpress.org/reference/functions/wp_cache_set_salted/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_cache_set_salted/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_cache_set_salted/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.9.0](https://developer.wordpress.org/reference/since/6.9.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_cache_set_salted%2F)
before being able to contribute a note or feedback.