Hello i’m quite new with php and i need some help figuring something out with my blog page. I have a list of articles currently displaying on the blog page and i want to specifically style the “latest” blog post but am not sure how to program this ( i know i probably need another if statement to select the first article). Right now i have this which is currently working. Anything helps… thanks!
If you just want to apply some different styles, I would also use a CSS selector. But if you want to use completely different markup, this should work (inside the foreach loop)…
<?php if ($article->uri() == $articles->first()->uri()): ?>
<!-- first article -->
<?php else: ?>
<!-- other articles -->
<?php endif; ?>
I hope you don’t mind me asking here but i feel that i have similar problem. i’m building a carousel which is structured as a list, this is what i have so far:
the first image shows up, but not the second. all i want to do is put the first image in the list item with the “current” class, and then have all remaining images go into a list item without any class. any recommendation on how to do this?
i have been trying to use the else statement but i’m new to php as well and it keep breaking my code…