Different code for each post instead of foreach ($posts as $post)?
-
Hey,
so, I created – or rather tried to create – a custom theme for my newsletter and came across the following problem:
<?php foreach ($posts as $post) { setup_postdata($post); ?>...<?php } ?>
This is the code that displays the number of recent posts as set in the post-part of the theme’s options, right? And whatever I put instead of … is displayed for every single one of those posts (for me it’s always six posts).
Now, my problem is that apparently most mail clients break every single layout that’s not purely based on tables, meaning that, since I want my six recent posts to be displayed in three rows, always to posts next to each other in one row, I somehow need to put them into different colums of my table-layout. Unfortunately, that simply doesn’t work if each post has the same code… (or I’m too stupid and just overlooked some really simple way to solve this?)
So, how can I change that
foreach ($posts as $post)
to something that makes it possible to have a different code for each post? Like:<table> <tbody> <tr> <td><?php something to call recent post 1 { ?>...<?php } ?></td> <td><?php something to call recent post 2 { ?>...<?php } ?></td> </tr> <tr> <td><?php something to call recent post 3 { ?>...<?php } ?></td> <td><?php something to call recent post 4 { ?>...<?php } ?></td> </tr> <tr> <td><?php something to call recent post 5 { ?>...<?php } ?></td> <td><?php something to call recent post 6 { ?>...<?php } ?></td> </tr> </tbody> </table>
Yeah, well, I don’t know anything about php or whatever so I don’t have any idea whether or not something like this is possible, but maybe someone here can help me?
Thanks a lot ??
- The topic ‘Different code for each post instead of foreach ($posts as $post)?’ is closed to new replies.