I have a "Nyheter" ("News") section on my index page.
(the loop on "nyheter")
<div id="nyheter">
<h2 class="headingStart1 underline"><a class="menu-nav" href="#">Nyheter</a></h2>
<?php query_posts('showposts=3&cat=5,'); if (have_posts()) : ?>
<ul id="customCategory1" class="group">
<?php while ( have_posts() ) : the_post() ?>
<li>
<a class="no-nav" href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark">
<div class="date">
<?php the_time('Y-m-d'); ?>
</div>
<h2 class="start">
<?php the_title(); ?>
</h2>
</a>
<?php the_content(); ?>
</li>
<?php endwhile ;?>
<?php endif; wp_reset_query();?>
</ul>
</div>
</li>
</div><!-- topLeft END!--->
When you "click" the news "post" you get to that category single page.
I want the "news" single-page to display rest of the "news" posts below.
(sigle.php)
<div id="container">
<div id="content" class="fullWidht">
<div class="headingStart1">Nyheter</div>
<li>
<div class="prodWrapper">
<div class="prodInfo">
<?php while ( have_posts() ) : the_post() ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<h2><?php $my_textbox_value = mtbxr_val("pris");
echo $my_textbox_value;?></h2>
</div><!-- prodInfo -->
<div class="prodPic">
<?php if (has_post_thumbnail()){;?>
<?php the_post_thumbnail('prodPic');?>
<?php }?>
</div>
</div>
</li>
<?php endwhile ;?>
Francisco Javier Carazo Gil answers:
Below it (in your single page) you can add it telling (do not include this post):
<div id="nyheter">
<h2 class="headingStart1 underline"><a class="menu-nav" href="#">Nyheter</a></h2>
<?php
$args=array(
'category__in' => array(5),
'post__not_in' => array(get_the_ID())
);
query_posts($args);
?>
<?php query_posts($args); if (have_posts()) : ?>
<ul id="customCategory1" class="group">
<?php while ( have_posts() ) : the_post() ?>
<li>
<a class="no-nav" href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark">
<div class="date">
<?php the_time('Y-m-d'); ?>
</div>
<h2 class="start">
<?php the_title(); ?>
</h2>
</a>
<?php the_content(); ?>
</li>
<?php endwhile ;?>
<?php endif; wp_reset_query();?>
</ul>
</div>
</li>
</div><!-- topLeft END!--->
Francisco Javier Carazo Gil comments:
With the parameter post_not_in you exclude current post, so you have:
FIRST single page like before
AFTER all the rest of pages
Francisco Javier Carazo Gil comments:
Remember to set <?php wp_reset_query(); ?> between the first part and the rest.
We would have:
<div id="container">
<div id="content" class="fullWidht">
<div class="headingStart1">Nyheter</div>
<li>
<div class="prodWrapper">
<div class="prodInfo">
<?php while ( have_posts() ) : the_post() ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<h2><?php $my_textbox_value = mtbxr_val("pris");
echo $my_textbox_value;?></h2>
</div><!-- prodInfo -->
<div class="prodPic">
<?php if (has_post_thumbnail()){;?>
<?php the_post_thumbnail('prodPic');?>
<?php }?>
</div>
</div>
</li>
<?php endwhile ;?>
<?php wp_reset_query(); ?>
<h2 class="headingStart1 underline"><a class="menu-nav" href="#">Nyheter</a></h2>
<?php
$args=array(
'category__in' => array(5),
'post__not_in' => array(get_the_ID())
);
query_posts($args);
?>
<?php query_posts($args); if (have_posts()) : ?>
<ul id="customCategory1" class="group">
<?php while ( have_posts() ) : the_post() ?>
<li>
<a class="no-nav" href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark">
<div class="date">
<?php the_time('Y-m-d'); ?>
</div>
<h2 class="start">
<?php the_title(); ?>
</h2>
</a>
<?php the_content(); ?>
</li>
<?php endwhile ;?>
<?php endif; wp_reset_query();?>
</ul>
</div>
</li>
</div><!-- topLeft END!--->
Francisco Javier Carazo Gil comments:
Remember to set <?php wp_reset_query(); ?> between the first part and the rest.
We would have:
<div id="container">
<div id="content" class="fullWidht">
<div class="headingStart1">Nyheter</div>
<li>
<div class="prodWrapper">
<div class="prodInfo">
<?php while ( have_posts() ) : the_post() ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<h2><?php $my_textbox_value = mtbxr_val("pris");
echo $my_textbox_value;?></h2>
</div><!-- prodInfo -->
<div class="prodPic">
<?php if (has_post_thumbnail()){;?>
<?php the_post_thumbnail('prodPic');?>
<?php }?>
</div>
</div>
</li>
<?php endwhile ;?>
<?php wp_reset_query(); ?>
<h2 class="headingStart1 underline"><a class="menu-nav" href="#">Nyheter</a></h2>
<?php
$args=array(
'category__in' => array(5),
'post__not_in' => array(get_the_ID())
);
query_posts($args);
?>
<?php query_posts($args); if (have_posts()) : ?>
<ul id="customCategory1" class="group">
<?php while ( have_posts() ) : the_post() ?>
<li>
<a class="no-nav" href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark">
<div class="date">
<?php the_time('Y-m-d'); ?>
</div>
<h2 class="start">
<?php the_title(); ?>
</h2>
</a>
<?php the_content(); ?>
</li>
<?php endwhile ;?>
<?php endif; wp_reset_query();?>
</ul>
</div>
</li>
</div><!-- topLeft END!--->
Hariprasad Vijayan answers:
Hello,
Try this
<div id="container">
<div id="content" class="fullWidht">
<div class="headingStart1">Nyheter</div>
<li>
<div class="prodWrapper">
<div class="prodInfo">
<?php while ( have_posts() ) : the_post() ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<h2><?php $my_textbox_value = mtbxr_val("pris");
echo $my_textbox_value;?></h2>
</div><!-- prodInfo -->
<div class="prodPic">
<?php if (has_post_thumbnail()){;?>
<?php the_post_thumbnail('prodPic');?>
<?php }?>
</div>
</div>
</li>
<?php endwhile ;?>
<?php
$args = array('showposts' => 3, 'cat' => 5,'post_not_in'=>get_the_ID());
query_posts($args); if (have_posts()) : ?>
<ul id="customCategory1" class="group">
<?php while ( have_posts() ) : the_post() ?>
<li>
<a class="no-nav" href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark">
<div class="date">
<?php the_time('Y-m-d'); ?>
</div>
<h2 class="start">
<?php the_title(); ?>
</h2>
</a>
<?php the_content(); ?>
</li>
<?php endwhile ;?>
<?php endif; wp_reset_query();?>
</ul>
Sébastien | French WordpressDesigner answers:
not sur to understand
you want to display the next posts
that's it ?
In this case use query_posts and offset
[[LINK href="http://codex.wordpress.org/Making_Custom_Queries_using_Offset_and_Pagination"]]http://codex.wordpress.org/Making_Custom_Queries_using_Offset_and_Pagination[[/LINK]]
Arnav Joy answers:
try this
<div id="container">
<div id="content" class="fullWidht">
<div class="headingStart1">Nyheter</div>
<li>
<div class="prodWrapper">
<div class="prodInfo">
<?php while ( have_posts() ) : the_post() ?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
<h2><?php $my_textbox_value = mtbxr_val("pris");
echo $my_textbox_value;?></h2>
</div><!-- prodInfo -->
<div class="prodPic">
<?php if (has_post_thumbnail()){;?>
<?php the_post_thumbnail('prodPic');?>
<?php }?>
</div>
</div>
</li>
<?php endwhile ;?>
<?php query_posts('showposts=3&cat=5,'); if (have_posts()) : ?>
<ul id="customCategory1" class="group">
<?php while ( have_posts() ) : the_post() ?>
<li>
<a class="no-nav" href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark">
<div class="date">
<?php the_time('Y-m-d'); ?>
</div>
<h2 class="start">
<?php the_title(); ?>
</h2>
</a>
<?php the_content(); ?>
</li>
<?php endwhile ;?>
<?php endif; wp_reset_query();?>
</ul>
Deepak answers:
Please try the youtube videos link may help you to solve your bug
http://www.youtube.com/watch?v=tvwWbrjYlkI
or
http://www.youtube.com/watch?v=izVJdfS5YUA