Wordpress Themes - WP Forum at BFA
There will be no more development for Atahualpa (or any other theme), and no support. Also no new registrations. I turned off the donation system. I may turn the forum to read only if it gets abused for spam. Unfortunately I have no time for the forum or the themes. Thanks a lot to the people who helped in all these years, especially Larry and of course: Paul. Take care and stay healthy -- Flynn, Atahualpa developer, Sep 2021

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Header configuration & styling »

How to show alternating items of two categories on one page


  #1  
Old Oct 22, 2009, 07:14 AM
Sakshin
 
66 posts · Aug 2009
Amsterdam, Netherlands
I' made something myself but it comes out as a mess. have a look at newspiration.com/news/archive/ and you see what I mean. Below is the template I used but it doesn't give me the result I would like to see; alternating items of two categories on one page. Isn't there a neater way of doing this with perfect result?

<?php
/*
Template Name: twocol_archive
*/
?>

<?php /* get all options: */
include (TEMPLATEPATH . '/functions/bfa_get_options.php');
get_header(); ?>

<div class="txtboxarchive1">

<p><h3>This week's inspiring news</h3></p>

<?php if ( is_page('197') ) { ?>
<?php $my_query = new WP_Query('category_name=news&showposts=1');
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<h3><?php the_title(); ?></h3>
<?php the_excerpt(); ?>
<?php endwhile; ?>
<?php } ?>

<?php if ( is_page('197') ) { ?>
<?php $my_query = new WP_Query('category_name=inspiration&showposts=1');
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<h3><?php the_title(); ?></h3>
<?php the_content(); ?><br />
<?php endwhile; ?>
<?php } ?>

<?php if ( is_page('197') ) { ?>
<?php $my_query = new WP_Query('category_name=news&showposts=1&offset=1' );
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<h3><?php the_title(); ?></h3>
<?php the_excerpt(); ?>
<?php endwhile; ?>
<?php } ?>

<?php if ( is_page('197') ) { ?>
<?php $my_query = new WP_Query('category_name=inspiration&showposts=1&of fset=1');
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<h3><?php the_title(); ?></h3>
<?php the_content(); ?><br />
<?php endwhile; ?>
<?php } ?>

<?php if ( is_page('197') ) { ?>
<?php $my_query = new WP_Query('category_name=news&showposts1&offset=2') ;
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<h3><?php the_title(); ?></h3>
<?php the_excerpt(); ?>
<?php endwhile; ?>
<?php } ?>

<?php if ( is_page('197') ) { ?>
<?php $my_query = new WP_Query('category_name=inspiration&showposts1&off set=2');
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<h3><?php the_title(); ?></h3>
<?php the_content(); ?><br />
<?php endwhile; ?>
<?php } ?>

<?php if ( is_page('197') ) { ?>
<?php $my_query = new WP_Query('category_name=news&showposts=1&offset=3' );
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<h3><?php the_title(); ?></h3>
<?php the_excerpt(); ?>
<?php endwhile; ?>
<?php } ?>

<?php if ( is_page('197') ) { ?>
<?php $my_query = new WP_Query('category_name=inspiration&showposts=1&of fset=3');
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<h3><?php the_title(); ?></h3>
<?php the_content(); ?><br />
<?php endwhile; ?>
<?php } ?>

<?php if ( is_page('197') ) { ?>
<?php $my_query = new WP_Query('category_name=news&showposts=1&offset=4' );
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<h3><?php the_title(); ?></h3>
<?php the_excerpt(); ?>
<?php endwhile; ?>
<?php } ?>

<?php if ( is_page('197') ) { ?>
<?php $my_query = new WP_Query('category_name=inspiration&showposts=1&of fset=4');
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<h3><?php the_title(); ?></h3>
<?php the_content(); ?>
<?php endwhile; ?>
<?php } ?>

<?php /* If there are any posts: */
if (have_posts()) : $bfa_ata['postcount'] == 1; /* Postcount needed for option "1 first posts full posts" */ ?>

</div>


<div class="clear"></div>
<?php /* END of: If there are any posts */
else : /* If there are no posts: */ ?>

<?php /* This outputs the "Not Found" content, if neither posts, pages nor attachments are available for the requested page.
This can be edited at Atahualpa Theme Options -> Style & edit the Center column */
bfa_center_content($bfa_ata['content_not_found']); ?>

<?php endif; /* END of: If there are no posts */ ?>



<?php get_footer(); ?>
  #2  
Old Oct 22, 2009, 07:23 AM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
I don't know if this is because of a typo during the copy and paste into the post, but the '&offset' in several of your WP_query's is '&off set' <- note the blank. If that is in the code, try removing it.
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #3  
Old Oct 22, 2009, 07:39 AM
Sakshin
 
66 posts · Aug 2009
Amsterdam, Netherlands
It's a copy/paste thing. In the file itself it's without the whitespaces. Any further advice?
  #4  
Old Oct 22, 2009, 07:49 AM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
I'm not sure what you are trying to do. Do you only want one item from each and have them alternate? Saying someting is a mess may make sence to you, but for someone else looking at the issue for the first time, how do I know what you mean by mess?

Try to be specific as to what the problem is.
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #5  
Old Oct 22, 2009, 08:15 AM
Sakshin
 
66 posts · Aug 2009
Amsterdam, Netherlands
My appologies if I'm not clear enough.
The result you can see here at n e w s p i r a t i o n . c o m / n e w s / a r c h i v e /

The idea is that on one page we get two catergories. The posts will be placed every friday and have to be shown above eachother. The last post of category news, the last post of category inspiration, the second last post of news, the second last post of inspiration, etc. Untill it fills the whole page.
To achief this I work with specific calls of catergories and to have them in the order I want I use the offset; the offset=1, offset=2 etc.
But somehow the end result is not at all like this, only the first three posts show up like this and then it becomes a mess and even double posts appear...
I feel I need to throw some code away from the file, but what?

Last edited by Sakshin; Nov 5, 2009 at 07:54 AM.
  #6  
Old Oct 26, 2009, 10:16 AM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
I think you are running into an issue where your putting info out, and so is 'The LOOP'

Try putting this at the top of 'The LOOP'
HTML Code:
<?php if (!is_page('197') ) { ?>
and this at the bottom of 'The LOOP'
HTML Code:
<?php } ?>
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #7  
Old Nov 2, 2009, 02:54 PM
Sakshin
 
66 posts · Aug 2009
Amsterdam, Netherlands
I did what you suggested and the loop look like this now;

<?php if (!is_page('197') ) { ?>
<?php /* Post Container starts here */ if ( function_exists('post_class') ) { ?>
<div <?php if ( is_page() ) { post_class('post'); } else { post_class("$odd_or_even"); } ?> id="post-<?php the_ID(); ?>">
<div <?php if ( is_category() ) { post_class('post'); } else { post_class("$odd_or_even"); } ?> id="post-<?php the_ID(); ?>">

<?php } else { ?>
<div class="<?php echo ( is_page() ? 'page ' : '' ) . $odd_or_even . ' post" id="post-'; the_ID(); ?>"> <?php } ?>
<?php bfa_post_kicker('<div class="post-kicker">','</div>'); ?>
<?php bfa_post_headline('<div class="post-headline">','</div>'); ?> <?php bfa_post_byline('<div class="post-byline">','</div>'); ?>
<?php bfa_post_bodycopy('<div class="post-bodycopy clearfix">','</div>'); ?>
<?php bfa_post_pagination('<p class="post-pagination"><strong>'.__('Pages:','atahualpa').'</strong>','</p>'); ?>
<?php bfa_post_footer('<div class="post-footer">','</div>'); ?> </div>
<!-- / Post -->
<?php } ?>

I even tried to delete the whole loop but that gave other problems on the site...
What to to next?

Sakshin.
  #8  
Old Nov 2, 2009, 02:56 PM
Sakshin
 
66 posts · Aug 2009
Amsterdam, Netherlands
So i forgot to write in the above message that the end result is the same, nothing changed.
  #9  
Old Nov 16, 2009, 09:06 AM
Sakshin
 
66 posts · Aug 2009
Amsterdam, Netherlands
Hello jugledad. Are you there? Can you shine some light on this issue? Please.

Bookmarks



Similar Threads
Thread Thread Starter Forum Replies Last Post
Do not show one or more categories in recent post list megatrader Page & Category Menu Bars 4 Oct 5, 2009 12:16 PM
[SOLVED] Alternating color for post on homepage viscouse Post-Kicker, -Byline & -Footer 3 Jun 25, 2009 08:08 PM
pagination problem - page 2 of categories don't show up! collymore Page & Category Menu Bars 2 May 17, 2009 09:38 AM
Show empty categories olsonsp4c Page & Category Menu Bars 2 Apr 22, 2009 11:41 PM
how to show only categories with a high number of posts ? elpidiofilho Atahualpa 3 Wordpress theme 4 Mar 17, 2009 03:43 PM


All times are GMT -6. The time now is 11:26 PM.


Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.