Hi Finally figured it out. I realized that mistyped repeater sub name. Anyway since it’s only 6 items, for now this is my solution. Thank you for helping to start!
<?php
$row_html = array();
while(have_rows('repeater')) {
the_row();
$index = get_row_index();
$row_html[$index] = get_sub_field('repeatersub');
}
$count = count($row_html);
if($count==1) {
echo 'Im 1';
}
elseif($count==2){
echo 'Im 2';
echo $row_html[2];
echo $row_html[1];
}
elseif($count==3){
echo 'Im 3';
echo $row_html[3];
echo $row_html[1];
echo $row_html[2];
}
elseif($count==4){
echo 'Im 4';
echo $row_html[4];
echo $row_html[1];
echo $row_html[2];
echo $row_html[3];
}
elseif($count==5){
echo 'Im 5';
echo $row_html[2];
echo $row_html[4];
echo $row_html[3];
echo $row_html[5];
echo $row_html[1];
}
elseif($count==6){
echo 'Im 6';
echo $row_html[5];
echo $row_html[6];
echo $row_html[3];
echo $row_html[2];
echo $row_html[1];
echo $row_html[4];
}
else {
echo 'None';
}
?>
Hi thank you. but I’m wondering, even if I have more than 2 items , the output is still 2? even though I set a condition if there are 3 items but still at your example it echoed 2. also switch case seem not working for count function. I don’t know but I really tried count function for repeater but doesn’t show correct output. it always shows “1” even if i have multiple rows. please help me. More important is that it counts the repeater rows then get each item that will put manually. thanks
hi I’m wondering why code won’t work when I put else if? I’m planning to do it manually since it will only have maximum of 6 items
<?php $row_html = array();
while(have_rows('repeater')) {
the_row();
$index = get_row_index();
$row_html[$index] = '<div>';
$row_html[$index] .= get_sub_field('repeater_sub');
$row_html[$index] .= '</div>';
} ?>
<?php if (($row_html[$index])<=2) {
echo 'test 2 items';
} else if (($row_html[$index])<=3) {
echo 'test 3 items';
} else {
echo 'Test';
} ?>
please help. Thank you
yes because i am creating a generator for newsletter. i hope there were possible solutions
Hello the question was updated:
http://wordpress.stackexchange.com/questions/184045/query-post-from-field-with-multiple-values-acf-advanced-custom-fields
Is it impossible if I only use text fields?
because there is a chance that user is going to input new hobbies and sports. If I use checkbox, What im gonna do? Do you mean that Whatever I type in the custom fields inside the post, It will going to populate the checkbox field on the “Page query template”? Sorry im not really good at php that’s why
could someone please help me?
Hi @elliot,
sorry for the confusion.. i was trying to loop a post by terms under taxonomy.
Post type: Video
taxonomy: Topics
terms under topics:
– Videos
* Video type 1 (sub)
* Video type 1 (sub)
* Video type 1 (sub)
* Video type 1 (sub)
hierarchy correction :
– Topic
* Type a
* Type b
* Type c
* Type d
Hi @elliot , how can i do that?
I just want to sort the demo post like this:
Demo post 11
Demo post 13
Demo post 15
Demo post 10
The field is locked..
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.