Adding to the Single post page all blog posts
-
Hi,
not sure if this is the correct category where I should ask this question but..
How do I add all my posts to the single post page right under the single post.
I hope you understand what I mean ??
setup would be:
– the single post that you wanted to see
– comment area
– all the blog posts from the index pageAnyone a clue?
-
The whole point of the single.php template is that it’s for a single post.
esmi yea great… but I have seen it on a few sites.
And isnt the whole point of open source that you can adjust it to your likings?
And isnt the whole point of a support forum to help?This will show your posts as unordered list.
Edit single.php (or index.php if single.php does not exist) and find this code:<?php comments_template(); ?>
Now before or after this, meaning before or after your comment section, add the following code:
<ul> <?php wp_get_archives('type=postbypost&limit=20'); ?> </ul>
If you post thousands of articles it will be strange to post all of them, so they are limited to 20. To change the number of posts just change 20 with whatever number.
Cheers!
thx a bunch, but when i test it I only get the blog titles.
Would it be possible to display them just as any post is shown on the index page?
Well this is really advanced…
Find: <?php endif; ?> This is where the loop ends and then add this code.<?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("showposts=10&paged=$page"); while ( have_posts() ) : the_post() ?> <div class="post_excerpt" id="post-<?php the_ID(); ?>"> <h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3> <div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> — <?php the_tags(__('Tags: '), ', ', ' — '); ?> <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div> <?php the_excerpt(); ?> <div class="feedback"> <?php wp_link_pages(); ?> <?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?> </div> </div> <?php endwhile; ?> <p><?php posts_nav_link(); ?></p>
Now you will have 10 posts with content and all. If you want to have full content (really wonder why) than you can change <?php the_excerpt(); ?> with <?php the_content(__(‘(more…)’)); ?>.
To add some style to it you have the following classes:
.post_excerpt – surrounding 1 post.
.storytitle – the title
.meta – for the meta content
.feedback – for feedback sectionYou will have also page navigation links.
To channge the number of posts change 10 to whatever in showposts=10
<?php get_header(); ?> <div id="content-padding"> <div id="content"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="post-nav"> <span class="previous"><?php previous_post_link('%link') ?></span> <span class="next"><?php next_post_link('%link') ?></span> </div> <div class="post" id="post-<?php the_ID(); ?>" style="margin-top: 0;"> <table id="post-head"> <tr> <td id="head-date"> <div class="date"><span><?php the_time('M') ?></span> <?php the_time('d') ?></div> </td> <td> <div class="title"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"> <?php the_title(); ?></a></h2> <div class="postdata"> <span class="category"><?php the_category(', ') ?></span> <span class="right mini-add-comment"> <a href="#respond">Add comments</a> </span> </div> </div> </td> </tr> </table> <div class="entry"> <?php the_content('Continue reading »'); ?> <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?> <?php edit_post_link('Edit', '', ''); ?> </div><!--/entry --> <?php comments_template(); ?> </div><!--/post --> <?php endwhile; else: ?> <p style="margin-top:25px;">Sorry, no posts matched your criteria.</p> <p><?php posts_nav_link(); ?></p> <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("showposts=10&paged=$page"); while ( have_posts() ) : the_post() ?> <div class="post_excerpt" id="post-<?php the_ID(); ?>"> <h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3> <div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> — <?php the_tags(__('Tags: '), ', ', ' — '); ?> <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div> <?php the_excerpt(); ?> <div class="feedback"> <?php wp_link_pages(); ?> <?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?> </div> </div> <?php endwhile; ?> <p><?php posts_nav_link(); ?></p> <?php endif; ?>
shows no posts when i visit my single.php
btw the reason why I want/need this is because of link trades to specific blog posts. A visitors comes on a single post, but only reads that blog posts and forgets there are more blog posts. You can keep them a lot longer on your blog if you can show them the the other blog posts right under it.
Normally i would have said to give me more details, your site and perhaps the theme and would have fixed it as i done it for others. I told you, it is a bit advanced, but can be done without problems.
But having this discussions i sometimes left links to one of my sites and this made me a SPAMMER in the eyes of the moderators so i am a little bit upset now, do not worry I will get over it and perhaps get back after some days and help others because I love WordPress.
Till then, i wish you luck and hope someone will help you soon and not make fun of your wish.
Have a nice day!thanks
the theme is ithemes 1.8 btw ??
https://www.mangoorange.com/downloads/i3theme-1-8-classic.zipOK… bellow is the code what you need to change in single.php (all code)
You have some style to blend with the original theme. I told you earlier how to change the number of posts to show.Change all the content from single.php with this:
<?php get_header(); ?> <div id="content-padding"> <div id="content"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="post-nav"> <span class="previous"><?php previous_post_link('%link') ?></span> <span class="next"><?php next_post_link('%link') ?></span> </div> <div class="post" id="post-<?php the_ID(); ?>" style="margin-top: 0;"> <table id="post-head"> <tr> <td id="head-date"> <div class="date"><span><?php the_time('M') ?></span> <?php the_time('d') ?></div> </td> <td> <div class="title"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"> <?php the_title(); ?></a></h2> <div class="postdata"> <span class="category"><?php the_category(', ') ?></span> <span class="right mini-add-comment"> <a href="#respond">Add comments</a> </span> </div> </div> </td> </tr> </table> <div class="entry"> <?php the_content('Continue reading »'); ?> <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?> <p class="submeta">written by <strong><?php the_author(); ?></strong> <?php if(function_exists("the_tags")) the_tags('\\\\ tags: ', ', ', '<br />'); ?> </p> <?php edit_post_link('Edit', '', ''); ?> </div><!--/entry --> <?php comments_template(); ?> </div><!--/post --> <?php endwhile; else: ?> <p style="margin-top:25px;">Sorry, no posts matched your criteria.</p> <?php endif; ?> <div style="margin:30px 0;border-bottom:1px solid #CCC;border-top:1px solid #666;"></div> <!-- Start Showing All posts --> <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("showposts=10&paged=$page"); while ( have_posts() ) : the_post() ?> <div class="post" id="post-<?php the_ID(); ?>" style="margin-top: 0;"> <table id="post-head"> <tr> <td id="head-date"> <div class="date"><span><?php the_time('M') ?></span> <?php the_time('d') ?></div> </td> <td> <div class="title"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"> <?php the_title(); ?></a></h2> <div class="postdata"> <span class="category"><?php the_category(', ') ?></span> </div> </div> </td> </tr> </table> <div class="entry"> <?php the_excerpt(); ?> <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?> <p class="submeta">written by <strong><?php the_author(); ?></strong> <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>">read more...</a> </p> </div><!--/entry --> <?php endwhile; ?> <!-- End Showing All posts --> </div><!--/content --> <?php include_once("real-footer.php"); ?> </div><!--/left-col --> <?php $current_page = $post->ID; // Hack to prevent the no sidebar error include_once("sidebar-right.php"); ?> <?php get_footer(); ?>
thanks a lot for the work and all tips!
you are the one I needed on this board ??
- The topic ‘Adding to the Single post page all blog posts’ is closed to new replies.