How to stop loop in php and manually edit code for wordpress?
-
I am using a theme named ‘discover’ in which I have edited the php codes to use 6 boxes in a row on the front page; however, because of a loop function available in the element_boxes.php, whatever value I put for one box, appears for all the boxes, which obviously I don’t want. For example, if I change the heading title for a box, it changes for all the boxes to the same title. The php code is given below if it helps to understand:
<?php for ($i = 1; $i <= 6; $i++) { ?> <div class="two columns"> <div class="box-head"> <a>"><img src="<?php if(esc_url(of_get_option('box_image' . $i)) != NULL){ echo esc_url(of_get_option('box_image' . $i));} else echo get_template_directory_uri() . '/images/box' .$i. '.png' ?>" alt="<?php echo esc_html(of_get_option('box_head' . $i)); ?>" /></a> </div> <!--box-head close--> <div class="title-box"> <div class="title-head"><h1><?php if(esc_html(of_get_option('box_head' . $i)) != NULL){ echo esc_html(of_get_option('box_head' . $i));} else echo "Test1 heading" ?></h1></div></div> <div class="box-content"> <?php if(esc_textarea(of_get_option('box_text' . $i)) != NULL){ echo esc_textarea(of_get_option('box_text' . $i));} else echo "Nullam posuere felis a lacus tempor eget dignissim arcu adipiscing. Donec est est, rutrum vitae bibendum vel, suscipit non metus." ?> </div> <!--box-content close--> <div class="clear"></div> <span class="read-more"><a>"><?php _e('Read More' , 'discover'); ?></a></span> </div><!--boxes end-->
[Please post code & markup between backticks or use the code button. Your posted code has now been permanently damaged by the forum’s parser.]
Thanks in advance to take your time to read. I’d appreciate any help.
- The topic ‘How to stop loop in php and manually edit code for wordpress?’ is closed to new replies.