Title: Variable Data not recognized with nested spintax
Last modified: September 10, 2020

---

# Variable Data not recognized with nested spintax

 *  Resolved [TradeMalia](https://wordpress.org/support/users/trademalia/)
 * (@trademalia)
 * [5 years, 9 months ago](https://wordpress.org/support/topic/variable-data-not-recognized-with-nested-spintax/)
 * Hello,
 * I was trying to follow these instructions for nested spintax
 * [https://wordpress.org/support/topic/nested-spin-function/](https://wordpress.org/support/topic/nested-spin-function/)
 * I have some fields in my CSV file with variable data, wich are included in the
   spintax, but the data are not correctly recognized.
 * For example, I’ve included this line:
 * [my_process_spintax(“{La mejor|La|La última} {options[1]}”)]
 * In my CSV file ‘options[1]’ has 3 lines:
 * – Oferta
    – Novedad – Variedad
 * Thus, the expected result should be:
 * “La mejor oferta”
 * or…
 * “La última novedad”
 * etc….
 * Instead of that, The result is:
 * “La mejor options[1]”
 * or
 * “La última options[1]”
 * etc….
 * I supose the problem is because the field’s key of my csv is inluded inside the
   quotation marks, and I need how to resolve this problem, because in some cases
   I need to spin the results with several fields options
 * for example:
 * [my_process_spintax(“{La mejor|La|La última} {{options[1]}|{options_2[1]}|{options_3[
   1]}}”)]
 * Thank you in advance for helping me!
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fvariable-data-not-recognized-with-nested-spintax%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/variable-data-not-recognized-with-nested-spintax/#post-13435577)
 * Hi [@trademalia](https://wordpress.org/support/users/trademalia/),
 * > I supose the problem is because the field’s key of my csv is inluded inside
   > the quotation marks, and I need how to resolve this problem, because in some
   > cases I need to spin the results with several fields options
 * You would need to pass the import fields to a custom function that generates 
   the spintax and returns it. Here’s a rough example that you can modify as needed:
 *     ```
       function my_custom_spintax( $text1 = '', $options ) {
       	$output = '';	
       	$output .= my_process_spintax( $text1 ) . ' ';	
       	$options = '{' . implode( '|', $options ) . '}';	
       	$output .= my_process_spintax( $options );	
       	return trim( $output );
       }
       ```
   
 * Used like so:
 * `[my_custom_spintax("{La mejor|La|La última}",array({options[1]},{options_2[1]},{
   options_3[1]}))]`
 *  Thread Starter [TradeMalia](https://wordpress.org/support/users/trademalia/)
 * (@trademalia)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/variable-data-not-recognized-with-nested-spintax/#post-13445394)
 * Hello,
 * Thank you for the reply, but I think that code doesn’t resolve my problem. I 
   have the import fields in my text and in some cases they are spun as well.
 * Probably I haven’t explained correctly. I give you a real example. This is how
   the import fields are included in my text:
 * [https://prnt.sc/umm33b](https://prnt.sc/umm33b)
 * This is the result:
 * [https://prnt.sc/umm3v7](https://prnt.sc/umm3v7)
 * And the desired result should be this one:
 * [https://prnt.sc/umm556](https://prnt.sc/umm556)
 * I appreciate you wrote for me that PHP function, but I think that code doesn’t
   resolve my problem.
 * thanks!
    Caio
    -  This reply was modified 5 years, 8 months ago by [TradeMalia](https://wordpress.org/support/users/trademalia/).
 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/variable-data-not-recognized-with-nested-spintax/#post-13480192)
 * Hi [@trademalia](https://wordpress.org/support/users/trademalia/),
 * The solution is still similar – any time you need to use import elements in a
   function, they need to be passed as arguments to the function rather than inside
   the text. So, for example, you could do something like:
 * `[my_custom_spintax("{La mejor|La|La última} blah blah ***INSERTELEMENTHERE***",
   array({plural[1]},{pluralmin1[1]}))]`
 * Then, adjust the code so that it spins the text, then spins {plural[1]}|{pluralmin1[
   1]} and replaces ***INSERTELEMENTHERE*** with the result when returning the spun
   text.
 *  Plugin Author [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * (@wpallimport)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/variable-data-not-recognized-with-nested-spintax/#post-13558485)
 * [@trademalia](https://wordpress.org/support/users/trademalia/), I’m marking this
   as resolved since it’s been a while. Let us know if you still have questions.
 * Anyone else, please open a new topic.

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

The topic ‘Variable Data not recognized with nested spintax’ 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/)

 * 4 replies
 * 2 participants
 * Last reply from: [WP All Import](https://wordpress.org/support/users/wpallimport/)
 * Last activity: [5 years, 7 months ago](https://wordpress.org/support/topic/variable-data-not-recognized-with-nested-spintax/#post-13558485)
 * Status: resolved