wordpress - PHP - Targeting every 5th and 9th element in the loop -
I have an unlimited loop which is a loop for the wordpress post page. I have explored a simple loop, which is the element in the loop Counts and varies with 5th and 9th element Here is my loop: I knew I was almost there, but it was a bit stuck on. Thank you in advance. You can use it. featured post . My idea is to target every 5th and 9th element, but now it is targeting only the first 5 and 9th element
& lt; Div class = "loop" & gt; & Lt ;? Start Php / * Loop /? & Gt; & Lt ;? Php $ i = 1; While (is_pause ()): the_post (); If ($ i == 5) {? & Gt; & Lt; Articles & gt; & Lt; / Article & gt; & Lt ;! - Featured-post-end-here - & gt; & Lt ;? Php get_template_part ('content', $ post- & gt; post_type); ? & Gt; & Lt ;? Php} and if ($ i == 9) {? & Gt; & Lt; Articles & gt; & Lt; / Article & gt; & Lt ;! - Featured-post-end-here - & gt; & Lt ;? Php get_template_part ('content', $ post- & gt; post_type); ? & Gt; & Lt ;? Php} and {get_template_part ('content', $ post- & gt; post_type); } If ($ i == 9) {$ i = 0; } $ I ++; Endwhile; ? & Gt; & Lt; / Div & gt; & Lt ;! - .loop - & gt;
if ((($ i% 9) == 0) or (($ i% 5) == 0)) {// Featured Post}
Comments
Post a Comment