• Ok now… I wanted to make my own theme from scratch and followed some tutorials, about 70% successful till now, but I ran into a little problem.
    My design looks like this here, and in the middle of the page on the left side you’ll see 9 post boxes, and this is how I coded them in xhtml

    [code moderated per forum rules - please use the pastebin]

    So this far in I guess you know that the first div content-left contains the entire box which contains the first second and third row div's, in each and every one of those rows are 3 other div's and each of those 3 div's represents 1 post, how can I use the multi loop code to make the posts show up like I want them in the styling and order that I want them, and without diplicating?

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter ProToCooL

    (@protocool)

    Here’s the code here since I can’t edit my post anymore XD
    https://pastebin.com/C5a9wi0j

    a:
    the_loop
    https://codex.www.ads-software.com/The_Loop

    you may need a query:
    https://codex.www.ads-software.com/Function_Reference/query_posts

    you have a limited choice of ordering the posts:
    https://codex.www.ads-software.com/Class_Reference/WP_Query#Order_.26_Orderby_Parameters

    b:
    set a counter, and dependant on the counter value, open or close the ‘row’ div;
    the modulus operator is quite useful for this:
    https://php.net/manual/en/language.operators.arithmetic.php
    increment counter for each post;
    make a extra test for semi-full rows;

    example code:
    https://pastebin.com/VcxcArBb

    Thread Starter ProToCooL

    (@protocool)

    Thing is that in my css, each post has it’s own position in the row, if i use only one position code of my css then the post boxes will get either to close to one another or get out of the div’s borders, so that’ll need a little thinking.
    Thanks for the link i kinda figured what I need to to, for the loop, this ain’t just one there are 3 loops here so i’m gonna need to use multiple loops since I’m doing that definitively gonna need the query and as for the ordering of the posts i’m gonna go with days.

    each post has it’s own position in the row

    no big problem, this can easily b integrated into any code;
    example:
    <div class="a-post a-post-<?php echo $counter; ?> pos-<?php echo ($counter%3+1); ?> "><!--wordpress post<?php echo $counter; ?> starts-->

    this ain’t just one there are 3 loops

    unless there is a special query for each row, what is the purpose of three loops?

    for multiple loops without duplicating posts, see https://codex.www.ads-software.com/The_Loop#Multiple_Loops_in_Action

    Thread Starter ProToCooL

    (@protocool)

    Ok so like this then.
    I set all my rows and posts code in between <?php if( have_posts() ) : $counter = 0; $row_position = array('first', 'second', 'third'); while( have_posts() ) : the_post(); ?>

    Code Goes Here

    <?php else : echo 'no posts';	endif; ?>

    I got the part where I just copy your code and paste it 2 more times start the second row and third but don’t know which values to change.

    where I just copy your code and paste it 2 more times

    no – the code will automatically ‘jump’ to the next row, if one row is full with three posts – as long as there are more posts – not restricted to three rows

    (only if you want them labelled, you need to extent the $row_position = array('first', 'second', 'third');)…

    Thread Starter ProToCooL

    (@protocool)

    Thanks bro! You helped me out a lot, and solved this case ??
    But what happens if there is no more space, like for the 10-th post? XD

    Thread Starter ProToCooL

    (@protocool)

    They stack in the background behind the archives widget :S
    https://img825.imageshack.us/img825/360/unledvvc.jpg

    there is always space, i.e. the 10th post will start a new row.

    to avoid this, set the number of posts per page to 9 (dashboard-settings-reading-).

    the alignment/formatting depends on your stylesheet – there is nothing anyone can help you with by looking at an image.

    Thread Starter ProToCooL

    (@protocool)

    Ok then, this is my index-wordpress.php so far, and this is my index-xhtml.html.
    I did add the posts, on the content left, they are working fine and adding up through the css just fine, but the featured left slider only gets the first posts(the latest) to slide even though i tryed to get the query to get from the featured category the first 2 or 3 posts, it doesn’t do that it just gets 1 post, plus if i set the posts to 9 per page then I wouldn’t be able to show 2 posts on content-right area becouse the content-left would have already have 9 posts.

    but the featured left slider only gets the first posts

    change the number after ‘showposts’ in this line (line 26):

    $my_query = new WP_Query('category_name=Featured&showposts=1');

    get familiar with all possible query parameters:
    https://codex.www.ads-software.com/Class_Reference/WP_Query#Parameters

    plus if i set the posts to 9 per page then I wouldn’t be able to show 2 posts on content-right area becouse the content-left would have already have 9 posts.

    you might need to write a new query for the posts on the ‘content-right’ area; or at least use rewind_posts() before that code.
    https://codex.www.ads-software.com/Function_Reference/rewind_posts

    what two posts are you trying to show on the right?

    Thread Starter ProToCooL

    (@protocool)

    For the featured slider, i did try to set the number to 2 or 3, it didn’t work it only captured the newest post.
    As for the content-right the plan was to show any 2 posts from the News category.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘The Multiple Loop how to for 3 rows each row 3 posts?’ is closed to new replies.