Title: Variable in Spintax with function
Last modified: January 24, 2022

---

# Variable in Spintax with function

 *  Resolved [Carlos Favre](https://wordpress.org/support/users/carfavre/)
 * (@carfavre)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/variable-in-spintax-with-function/)
 * Hi, I’m trying to use the function to spin text and I can’t get it to take the
   import variables included in the text.
 * I have read the following Thread:
 * [https://wordpress.org/support/topic/variable-data-not-recognized-with-nested-spintax/](https://wordpress.org/support/topic/variable-data-not-recognized-with-nested-spintax/)
 * and I have tried to use the custom function you provide, but it always returns
   the field {localidad[1]} for example and I don’t care about the value of the 
   csv.
 * This is an example of how I am using it.
 * [my_custom_spintax(“{Best places|The Best places|Top places} in {location[1]}”,
   array({location[1]}))]
 * Please help me. Thanks !!!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/variable-in-spintax-with-function/#post-15306472)
 * Hi [@carfavre](https://wordpress.org/support/users/carfavre/),
 * For your example, you’d need to call the function like this:
 * `[my_custom_spintax("{Best places|The Best places|Top places} in ***PUTLOCATIONHERE***",{
   location[1]})]`
 * Then, change the “my_custom_spintax” function code to this:
 *     ```
       function my_custom_spintax( $text1 = '', $location ) {
       	$output = my_process_spintax( $text1 ) . ' ';	
       	$output = str_replace( "***PUTLOCATIONHERE***", $location, $output );
       	return trim( $output );
       }
       ```
   
 * I hope that helps.
 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/variable-in-spintax-with-function/#post-15447322)
 * [@carfavre](https://wordpress.org/support/users/carfavre/), I’m marking this 
   as resolved since it’s been inactive for over 1 month. Please open a new topic
   if you still have questions.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Variable in Spintax with function’ is closed to new replies.

 * ![](https://ps.w.org/wp-all-import/assets/icon-256x256.png?rev=2570179)
 * [WP All Import – Drag & Drop Import for CSV, XML, Excel & Google Sheets](https://wordpress.org/plugins/wp-all-import/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-all-import/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-all-import/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-all-import/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-all-import/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-all-import/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * Last activity: [4 years, 3 months ago](https://wordpress.org/support/topic/variable-in-spintax-with-function/#post-15447322)
 * Status: resolved