WordPress.org

Ready to get started?Download WordPress

Forums

Multiple content blocks
[resolved] Transfer block information to array (5 posts)

  1. gavinjsr
    Member
    Posted 6 months ago #

    Hi I am wondering there is a way to transfer the information from a block into an array.

    Thanks,

    Gavin

    http://wordpress.org/plugins/multiple-content-blocks/

  2. Harold Angenent
    Member
    Plugin Author

    Posted 6 months ago #

    Sure, you can put almost anything in an array. But I don't fully understand what you mean.

    You want to put the content of a block in an array? Like this?

    $my_array = array( get_the_block( 'My block' ) );
  3. gavinjsr
    Member
    Posted 6 months ago #

    Hi Harold.

    I have installed the multiple blocks plugin to allow the user to manage the postcodes allowed.

    ie:

    BT1AAA,BT1BBB,BT1CCC,BT1DDD

    So I then want to explode this into an array as such:

    $var = array("BT1AAA","BT1BBB","BT1CCC","BT1DDD");

    Thanks,

    Gavin

  4. Harold Angenent
    Member
    Plugin Author

    Posted 6 months ago #

    Okay.. this is kind of a PHP question and unrelated to our plugin, but I can give you some pointers:

    $postal_codes = get_the_block(  'Postal codes' ); //Or whatever the name is
    $postal_codes = explode( ',', $postal_code ); //Comma separated
  5. gavinjsr
    Member
    Posted 6 months ago #

    You're a Gentleman. I'll give that a go.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.