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 featured post . My idea is to target every 5th and 9th element, but now it is targeting only the first 5 and 9th element

Here is my loop:

  & 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;   

I knew I was almost there, but it was a bit stuck on.

Thank you in advance.

You can use it.

  if ((($ i% 9) == 0) or (($ i% 5) == 0)) {// Featured Post}   



Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -