Title: addslashes_strings_only
Published: November 12, 2019
Last modified: April 28, 2025

---

# addslashes_strings_only( mixed $value ): mixed

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/addslashes_strings_only/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/addslashes_strings_only/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/functions/addslashes_strings_only/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/addslashes_strings_only/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/addslashes_strings_only/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/functions/addslashes_strings_only/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/addslashes_strings_only/?output_format=md#user-contributed-notes)

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

This function has been deprecated since 5.6.0. Use [wp_slash()](https://developer.wordpress.org/reference/functions/wp_slash/)
instead.

Adds slashes only if the provided value is a string.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/addslashes_strings_only/?output_format=md#description)󠁿

### 󠀁[See also](https://developer.wordpress.org/reference/functions/addslashes_strings_only/?output_format=md#see-also)󠁿

 * [wp_slash()](https://developer.wordpress.org/reference/functions/wp_slash/)

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

 `$value`mixedrequired

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

 mixed

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

    ```php
    function addslashes_strings_only( $value ) {
    	return is_string( $value ) ? addslashes( $value ) : $value;
    }
    ```

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

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

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

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/addslashes_strings_only/?output_format=md#user-contributed-notes)󠁿

 1.  [Skip to note 2 content](https://developer.wordpress.org/reference/functions/addslashes_strings_only/?output_format=md#comment-content-6973)
 2.   [Yuvrajsinh Sisodiya](https://profiles.wordpress.org/yuvrajsinh2211/)  [  2 years ago  ](https://developer.wordpress.org/reference/functions/addslashes_strings_only/#comment-6973)
 3. [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Faddslashes_strings_only%2F%23comment-6973)
    Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Faddslashes_strings_only%2F%23comment-6973)
 4.     ```php
        /* Example usage of addslashes_strings_only() */ 
        $string     = "This is a string with 'quotes'";
        $non_string = 12345;
    
        $escaped_string     = addslashes_strings_only( $string );
        $escaped_non_string = addslashes_strings_only( $non_string );
    
        echo "Original String: $string";
        echo "Escaped String: $escaped_string";
    
        echo "Original Non-string: $non_string";
        echo "Escaped Non-string: $escaped_non_string";
        ```
    
 5.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Faddslashes_strings_only%2F%3Freplytocom%3D6973%23feedback-editor-6973)

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