Support » Fixing WordPress » Two looops – one div to display

  • To be as clear as i can, first i explane what i’m trying to achive:

    I have this testing site: http://www.wp-test-2.jabbo.cz/

    If you look under the slider, there are two columns – both of them have different loop in it. The left one is showing one post from category Novinky (News), the right one is showing one post prom category Recepty (Recepies). Well so far it works great. But – i have this layout only on front-page. If you click on title of the post you see that second column is now sidebar. Now – what i want. I want to display content of the post from right sidebar on fron-page to display in left column when you click on it at front-page. I hope you understand. So far – if i click on link to post from right column on front-page it displays the first post from category Novinky (News) not Recepies(Recepty) – it is logical, but i dont’t know how exactli can i switch content of left box.

    Now – to the code.

    There is my first loop (Novinky):

    <div id="primary">
            	<!-- smyčka - loop -->
                <?php query_posts('category_name=novinky&showposts=1'); ?> <!-- určuje kategorii, ze které se mají články vypisovat a počet zobrazených článků -->
    			<?php if(have_posts()) : while(have_posts()) : the_post(); ?>
                <div id="post-item">
                    <a href="#"><img src="<?php bloginfo('template_directory'); ?>/images/hrnec.jpg" alt="novinka"></a>
                    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <!-- nadpis s odkazem -->
                    <div class="entry-meta">napsal <?php the_author();?>, <?php the_date();?></div> <!-- metadata -->
                    <div class="entry-content">
                    <?php the_content ('více informací'); ?> <!-- obsah článku + text tlačítka "more" -->
    
                    </div>
                </div>
                <?php endwhile; ?>
                <?php else : ?>
                    <p>Nevím co hledáte</p> <!-- co se napíše, když nejsou žádné články -->
                <?php endif; ?>   
    
                <!-- Další/předchozí -->
                <div id="morePrev">
                	<?php next_posts_link('Další'); ?>
                    <?php previous_posts_link('Starší');?>
           		</div>
    
            </div>

    And second:

    <?php wp_reset_query(); ?>  <!-- reset nutné! -->
            <?php if ( have_posts() && is_front_page() ) : ?> <!-- pokud jsou příspěvky a jsme na front page -->
                <?php query_posts('category_name=recepty&showposts=1'); ?> <!-- vypiš první příspěvek z kategorie recepty -->
                <?php while(have_posts()) : the_post(); ?> 
    
                <div id="recept">
                <h2 class="recepty">Recepty</h2>
    
                <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <!-- nadpis s odkazem -->
                <a href="#"><img class="recepty-87x85" alt="Palačinky" src="<?php bloginfo('template_directory'); ?>/images/pancakes.png" /></a>
                <?php the_content ('více informací'); ?>
    
                <?php endwhile; ?>
                </div>
    
            <?php else : ?> <!-- pokud nesjou příspěvky a není na front page -->
                <ul id="sidebar-right">
                <p>zkušební oblast pro sidebar, widgety atd.</p>
    
                <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('sidebar-right') ) : ?> <!-- zavoláme sidebar -->
                <p>nepoužíváte dynamický sidebar!</p>
                <?php endif; ?>
                </ul>
            <?php endif; ?> <!-- konec smyčky -->

    Thanx for help.

  • The topic ‘Two looops – one div to display’ is closed to new replies.