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: https://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 zobrazenych ?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 dynamicky 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.