adrian7474
asked on
Display additional post titles on my home page
Hi, I am trying to put a div that will list out 10 additional post titles from the 10 already being displayed on my home page.
Basically, in the reading section of my admin panel, i have the post set to display 10 post. I would like to display the NEXT 10 additional post by title only. (to keep bandwidth and site-load down on my site).
I am experimenting (with the attached code) below the loop in the index.php file in my theme. I was reading the codex page of wordpress, but sadly, my php skills only go so far. I am getting it display the post titles however they are not formatted(listed out) and they are not the 10 additional post, but all of them.
Can someone help me tweak this to work properly?
Also, I read using two loops was bad, so if there is another way to do it, let me know.
Basically, in the reading section of my admin panel, i have the post set to display 10 post. I would like to display the NEXT 10 additional post by title only. (to keep bandwidth and site-load down on my site).
I am experimenting (with the attached code) below the loop in the index.php file in my theme. I was reading the codex page of wordpress, but sadly, my php skills only go so far. I am getting it display the post titles however they are not formatted(listed out) and they are not the 10 additional post, but all of them.
Can someone help me tweak this to work properly?
Also, I read using two loops was bad, so if there is another way to do it, let me know.
<?php
// test code for post box
$query = 'posts_per_page=10';
$queryObject = new WP_Query($query);
// The Loop...
if ($queryObject->have_posts()) {
while ($queryObject->have_posts()) {
$queryObject->the_post();
the_title();
}
}
?>
ASKER
I'm sorry, so where would i insert this code. Would it be in the loop? Like this?
<?php
// test code for post box
$query = 'posts_per_page=10';
$queryObject = new WP_Query($query);
// The Loop...
if ($queryObject->have_posts()) {
$i = 0;
while statement
{
echo the title
if ($i <10)
{
echo the body
}
$i++;
}
}
}
?>
p_nuts is partly right, set posts number to 20 in the reading section of your admin panel, then in the loop of the corresponding template count the posts, display first ten as usual, and then display the rest just the way you like it. Remember you can structure it and style it however you like. I believe it's just a matter of couple additional conditionals.
If you do not want to change posts number site-wide, then call query_posts('posts_per_pag e=20') just before your loop starts:
If you do not want to change posts number site-wide, then call query_posts('posts_per_pag
...
<?php query_posts('posts_per_page=20'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
...
ASKER
Guys, I can't get it working. Can someone place the exact code i would use?
Can you post the contents of corresponding template here? I will alter it as needed.
ASKER
sure. here is what i got so far.
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post() ?>
<?php include ('entry_main.php') ?>
<?php endwhile; ?>
<?php else : ?>
<li class="no-posts">
<h3>
<?php _e( 'No posts yet!', 'p2' ) ?>
</h3>
</li>
<?php endif; ?>
</ul>
<?php // test code for post box ?>
<?php rewind_posts(); ?>
<?php
query_posts('posts_per_page=10&offset=10');
echo the_title();
?>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
in principle if you don't want 2 queries...
select 20 records.
$i = 0;
while statement
{
echo the title
if ($i <10)
{
echo the body
}
$i++;
}