![]() |
Who here knows a little bit about Wordpress?
Lets say that you have 2 posts in a loop in order to have alternating looks for your posts.
How does Wordpress handle this? Will it work? |
Can you rephrase that ?
|
Quote:
I want to know how I can play with the loop in order to achieve this. |
DjSap knows WP
|
Like
POST 1 POST 2 And (as an example) POST 1 has black background, POST 2 has red back ground? I am sure there is a better way, and i haven't tested it, but you could try this: <table style="background:<?php if ($currentbg == "#000000") $currentbg = "yellow"; else { $currentbg = "#000000" } echo $currentbg; ?>">POST</table> And it would kind of do it for you. Sorry if it doesn't make sense. been up for about 27 hours so far... :( |
Actually, ignore my last post. Seems I read what you said, and just came up with my own idea of what you wanted. Sorry! (I need to go sleep now!)
|
But btw, as it is in a loop, just do a counter, and do something like this:
$counter = 0; while(whatever) { if ($counter == 0) { echo "<tr>"; } echo "<td>post</td>"; if ($counter == 2) { echo "</tr>"; $counter = -1; //to make up for the counter++ below } $counter++; } // next bit fixes it up, incase it just ends in <tr><td>post</td> if ($counter == 1 || $counter == 2) { if ($counter == 1) { echo "<td></td>"; } echo "</tr>"; } } something like that, anyway. and add <table>/</table>. that is if it is in a table, ofcourse |
That's a very bulky way of doing it :)
At the top of the page you put: <?$i;?> Then in index.php you sorround the post with this div: <div class="<?=($i%2)?"bg1":"bg2";$i++;?>"> In your style sheet you put: .bg1 {background-color: #FFF;} .bg2 {background-color: #000;} |
bump you
|
And if you separate the posts in categories and show each category in a different area?
|
Quote:
|
I think he would like put news into different areas of the index such kineda.com
You can't for example in left shows news of category1 and in right shows news of category 2? |
You can do that but it takes some time.
|
Quote:
|
Why can't people just make good original blogs the way they were meant to be. KISS is the principle I use and it has brought fortunes.
There is no short cuts unless you are a ruthless asshole that usually whines up dead. |
If I understand what you want correctly: areaA=a category and areaB=another category, query_posts() should do it:
http://codex.wordpress.org/Template_Tags/query_posts Two snags. The first that you would need a counter, which only ticked up when the category matched the one you were looking for, but that is easily adapted from one of the previous posts, if not explained on the page I linked to. The second is that you would need multiple loops, as explained here: http://codex.wordpress.org/The_Loop |
I know a LITTLE about Wordpress. I don't know this.
|
| All times are GMT -7. The time now is 04:48 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123