• Resolved et3rnal

    (@et3rnal)


    Hi,

    I had no problem with UF when the type is “Options Page” but I tried to use the same repeater code to read values from “Meta type” but it didn’t work!.
    So how to retrieve repeater values id the type set to “Options Page” and show page “In the Main Menu” ?

    this is what I have now

    <?php
    	foreach( get_uf_repeater('slider') as $document_files ): extract( $document_files )
    	?>
    		<div class="testing">
    			<?php echo $image_side ?>
    			<?php echo $the_image ?>
    		</div>
    	<?php
    	endforeach;
    	?>

    1 select and 1 image

    Thanks

    https://www.ads-software.com/plugins/ultimate-fields/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Same question here. I didn’t found any Docs… is there in any place?
    I created a repeater and added it to Main menu (Options Page), but can’t retrieve any data from the loop.

    I tryed to call it like this:

    foreach( get_uf_repeater('parallax')...
    or using just
    foreach( get_uf('parallax')

    But it always return this:
    Invalid argument supplied for foreach()

    Something very ODD happened then: I just change the repeater and added it to an especific page. Everything worked as expected, BUT putting back the repeater to be at Main Menu again, the foreach still worked. I thought it was fine, but actually it was retrieving the meta-data from the page. Even if I delete the repeater, the foreach still brings me data… It is doing a real mess in my DB.

    And I forgot to add something during these tests and the plugin broke my whole site… front and backend…

    So with no docs, no website, no answers in foruns, and being so unstable… It doesn’t worth.

    Plugin Author Radoslav Georgiev

    (@radogeorgiev)

    Hi guys! A few things (in kind of a reverse order) below:

    pisandelli, sadly right now I can agree with you. I’ve been “away” for quite a long time. This plugin is a side-project for me and unfortunately I didn’t have much resources for it, specifically the forum. The small amount of time I have, I’m using for version 2, which is going to be quite stable(r), more powerfull and better written.

    I’m 2/3 ready with the docs for version 1 (stuff is actually happening behind the scenes at ultimate-fields.com), but I’m focusing my time on the next version. Anyway, in the next couple of months I’ll try to be consistent here, so don’t lose hope :] Now with the actual answers:

    Datastores
    Ultimate Fields works with several data-stores to save the values in the database. Without going too deep, those datastores are objects that connect fields with the database. Each container uses a different datastore and the values are saved in a different place:

    • The Options Page container uses a datastore that saves the data as WordPress options (in the wp_options) table.
    • The Post Meta Box container uses a datastore that saves the values in the post meta (wp_postmeta) table

    When the values are saved in those tables, the normal WP APIs like get_option() and get_post_meta() can be used too.

    The uf() and get_uf() functions do two things:

    1. The main purpose is to mask get_option and get_post_meta to make it seem easier.
    2. The second/secondary purpose of these functions is to pre-process the values that are in the database.. For example, the image field only saves the ID of the image and that’s what you would get if you use get_option(). get_uf() retrieves that ID and after that retrieves the image from the media library.

    So, there are three functions:

    1. uf()
    2. get_uf()
    3. get_uf_repeater()

    All of them accept the same arguments, which are:

    1. key: That’s the key of the repeater. In both of your cases (slider and parallax) that’s right.
    2. type: This parameter can receive several types of values.

    Possible values/value combinations for the type variable:

    • Nothing: In that case the function will try to retrieve the values that are associated with the current post/page/post type.
    • Post ID (intereger): In this case, no matter the post type, the function will try to retrieve the data for the post with the given ID.
    • Option key (string): Tries to retrieve the value of a field that is displayed in an options page.
    • [Other Type]_[ID for the other type]: This would work like term_23 in the premium version, but is not really something that matters here.

    With all of the above said, now to the particular problems:

    et3rnal, just add ‘options’ as the second parameter of get_uf_repeater, so it would become:

    <?php
    foreach( get_uf_repeater('slider', 'option') as $document_files ): extract( $document_files )
    ?>
    	<div class="testing">
    		<?php echo $image_side ?>
    		<?php echo $the_image ?>
    	</div>
    <?php
    endforeach;
    ?>

    pisandelli, the fix is the same as the one above. What you observed though is something different:
    When you changed the type of the container to Post Meta and saved the page, the values got saved for that page. After you changed the type to Options Page again, the values were not deleted. That’s because the data from the plugin is only being deleted when it’s associated to a post and the post itself gets deleted. So when you tried accessing the value from the post meta, the value was still there and being displayed. If you try the same with another page, the problem will not persist.

    The conclusion is that the only messed up thing in your database is a single row in the wp_postmeta database, which compared to other plugins is basically nothing ??

    As for this part:

    And I forgot to add something during these tests and the plugin broke my whole site… front and backend

    One of the things I don’t like in the current version is the lack of if statements here and there and that shows here. Please create a thread with the particular error so we can try to fix it. In the meantime, rename the folder of the plugin so it will get deactivated and at least the other part of the site will work.

    Best regards,
    Rado

    Thread Starter et3rnal

    (@et3rnal)

    Thanks you for the great detailed replay, looking forward for the 2nd version ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘get repeater values from Post Meta type’ is closed to new replies.