• Resolved Daniel

    (@dmzayasplus)


    Hello all!

    I read the support question about limiting the output of the repeater fields. I tried this using the solution displayed but it outputs the last repeater entry instead of the first…

    Anyone got a php trick to output the first repeater entry?

    Thanks in advance!

    https://wordpress.org/plugins/ultimate-fields/

Viewing 4 replies - 1 through 4 (of 4 total)
  • I’m not sure what trick you saw, but if you want the first entry why not use array_shift( $repeater ) ( http://php.net/array_shift ) ?

    Plugin Author Radoslav Georgiev

    (@radogeorgiev)

    Hi dmzayasplus,

    I’m sorry that I was away for kinda too long, but I’m supporting this project in my free time and lately it seems to be mostly absent.

    I’m not fully sure what you are trying to achieve. The array_chunk function splits arrays into parts, which has a totally different purpose that outputting just the first entry from an array (repeater).

    If you only need the first entry from a repeater, you can try something like this:

    $repeater_data = get_uf_repeater( 'key' );
    $first_entry = array_shift( $repeater_data );
    echo $first_entry[ 'field_key' ];

    Still, I wouldn’t do that, as using only the first entry of a repeater, in most cases, means that you don’t really need the repeater at all.

    If this does not answer your question, please include an export of the container so I can see what you’re trying to achieve. Then it would be much easier for me to help you 🙂

    Plugin Author Radoslav Georgiev

    (@radogeorgiev)

    I’m marking the topic as resolved, as there has been no answer for more than a week. If there’s anything wrong, feel free to open it again.

    Thread Starter Daniel

    (@dmzayasplus)

    I will try that and get back to you. I am using a repeater for a list of items on a weekly post, but I want to dynamically load the home page with the latest #1 item from the new post each week. So if I query the category of post, I should be able to grab the repeater and only output the #1 item to display on the home page. 😀

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘array_chunk outputs last repeater’ is closed to new replies.