Support » Fixing WordPress » Complicated 3 Loops and Pagination on Category.php

  • Hi guys,

    I suare I’ve tried everything! Closest post I’ve found was http://wordpress.org/support/topic/320679?replies=12 I googled it, etc etc and I couldn’t find the answer. Could you help me out please?

    Here’s the scenario:
    Category page:
    — page —
    -col 1-
    showposts 1
    /* loop for 1 div with style A */
    endwhile;
    showposts 3
    /* 3 divs with style B */
    endwhile;
    -end col 1-
    -col 2-
    showposts 5
    /* 5 divs with style C */
    endwhile;
    -end col 2-
    -col 3-
    /* stuff */
    -end col 3-
    pagination;
    — end page —

    It’ll be great to use another layout if it’s paged, but I could go live with the above working as I’d like.

    Thanks guys!

    Chocks.-

Viewing 4 replies - 1 through 4 (of 4 total)
  • I’m not sure that the problem is.

    Sorry that I didnt explain the problem correctly. The issue is that I run the following loops:
    Above the first loop:

    foreach(get_the_category() as $category)
    		{ $thecat = $category->cat_ID; }

    // So I know which cat id it is.
    Loop 1:

    $my_query = new WP_Query('showposts=1&offset=0&cat'.$thecat.'');
    		while ($my_query->have_posts()) : $my_query->the_post();
    		$do_not_duplicate = $post->ID;
    		$image = get_post_meta($post->ID, "pft_principal", $single = true);

    Result: ok
    Loop 2:

    $my_query = new WP_Query('showposts=3&offset=1&cat'.$thecat.'');
    		while ($my_query->have_posts()) : $my_query->the_post();
    		$image_2 = get_post_meta($post->ID, "pft_secundaria", $single = true);

    Result: posts in every category instead of the single cat.
    Loop 3:

    $my_query = new WP_Query('showposts=5&offset=4&cat'.$thecat.'');
    		while ($my_query->have_posts()) : $my_query->the_post();
    		$image = get_post_meta($post->ID, "pft_principal", $single = true);

    Result: Same as above. Offset working but it’s not displaying posts from that category only.
    It’s also breaking the footer! God knows why.. and pagination is not working either.. any clue? I’m desperate!

    Try:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args= array(
    	'posts_per_page' => '1',
    	'offset' => 0,
    	'cat' => $thecat,
    	'paged' => $paged
    );
    $my_query = new WP_Query($args);
    ?>

    Thanks for your reply esmi. Unfortunately it didn’t work. If I execute:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args= array(
    	'posts_per_page' => '1',
    	'offset' => 0,
    	'cat' => $thecat,
    	'paged' => $paged
    );
    $my_query = new WP_Query($args);
    $foto_secundaria = get_post_meta($post->ID, "pft_secundaria", $single = true);
    ?>

    I retrieves the first post but doesn’t show the excerpt and the pagination doesn’t work either..
    If I add at the bottom of the code, before “?>”:
    while ($wp_query->have_posts()) : $wp_query->the_post();
    It shows the loop as a standard one.. any other idea?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Complicated 3 Loops and Pagination on Category.php’ is closed to new replies.