Wordpress Themes - WP Forum at BFA
There will be no more development for Atahualpa (or any other theme), and no support. Also no new registrations. I turned off the donation system. I may turn the forum to read only if it gets abused for spam. Unfortunately I have no time for the forum or the themes. Thanks a lot to the people who helped in all these years, especially Larry and of course: Paul. Take care and stay healthy -- Flynn, Atahualpa developer, Sep 2021

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme »

[SOLVED] Recent posts of same category, on single post pages


  #1  
Old Apr 30, 2009, 10:23 AM
GeoParadise
 
6 posts · Apr 2009
Hello again! When the user is reading a post (on a sigle post page) which belongs to one category, is it possible that the next/prev page navigation shows only posts inside the same category? Or, if not possible, would it be possible to have in the sidebar a list of all the other posts on that category?
Because, currently it shows the newer/older post of all categories making it difficult to navigate inside one category without having to go back again to the category multipost page. I hope the question make sense.
Again, our blog is:
www.geoparadise.org/blog
Thanks in advance!
NOA
  #2  
Old Apr 30, 2009, 03:37 PM
Flynn's Avatar
Flynn
 
3,768 posts · Oct 2008
Munich, Germany
You can put this into a PHP code widget http://wordpress.org/extend/plugins/php-code-widget/

PHP Code:
<?php if ( is_category() ) {
global 
$wp_query;
$current_cat_id $wp_query->get_queried_object_id(); ?>
<div id="category-posts-<?php echo $current_cat_id?>" class="widget widget_recent_entries">
<div class="widget-title"><h3><?php single_cat_title('Recently in '); ?>:</h3></div>
<div class="widget-content">
<ul>
<?php global $post$cat_posts get_posts('numberposts=10&category='.$current_cat_id);
foreach(
$cat_posts as $post) : ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
</div>
</div>
<?php ?>
  #3  
Old May 7, 2009, 11:12 AM
GeoParadise
 
6 posts · Apr 2009
Hello Flynn! Thanks for your answer.
I did it, but I canīt see any change at all!! What was supposed to be doing?

Noa
  #4  
Old May 7, 2009, 11:29 AM
Flynn's Avatar
Flynn
 
3,768 posts · Oct 2008
Munich, Germany
It should have listed the recent posts of the given category in the sidebar, when on a category page. Did you install the plugin? After that you should put one instance of the PHP code widget into a sidebar, and into the widget put the above code
  #5  
Old May 8, 2009, 04:13 PM
GeoParadise
 
6 posts · Apr 2009
Ok! Sorry, I was trying with the widget Php Code that comes with the theme, but now Iīve installed the plugin from your link and done everything again, and it certainly shows a list with the lasts posts of the category in the sidebar, like you said, but it does it in the Category MULTIPOST Page, which doesnīt give any extra functionality, as long as they are also listed in the center/main space.
What we would need and appreciate is to have that list/menu of the lasts entries on that category in the sidebar, but on the SINGLE Post Pages. (or otherwise, change the next/prev nav menu to show only post inside the category). I hope is possible...
Thanks again!
NOA
  #6  
Old May 8, 2009, 04:47 PM
Flynn's Avatar
Flynn
 
3,768 posts · Oct 2008
Munich, Germany
Use this instead:
PHP Code:
<?php
if (is_single( )) {
$post_ID $wp_query->posts[0]->ID;
$all_cats_of_post get_the_category($post_ID);
$first_cat_ID $all_cats_of_post[0]->cat_ID;
$first_cat_name $all_cats_of_post[0]->cat_name;
?>
<div id="category-posts-<?php echo $first_cat_ID?>" class="widget widget_recent_entries">
<div class="widget-title"><h3>Recently in <?php echo $first_cat_name?>:</h3></div>
<div class="widget-content">
<ul>
<?php global $post$cat_posts get_posts('numberposts=10&category='.$first_cat_ID);
foreach(
$cat_posts as $post) : ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
</div>
</div>
<?php ?>
  #7  
Old May 8, 2009, 04:56 PM
paulae's Avatar
paulae
 
1,333 posts · Feb 2009
Wordpress 3.4.1, Atahualpa 3.7.7
I found a really easy way to do this: http://wordpress.org/extend/plugins/category-posts/

It's a widget that lets you put a certain number of posts from a category in the sidebar, showing up just in that category.
  #8  
Old Jan 4, 2010, 10:47 PM
Grant R Brown
 
2 posts · Jan 2010
Hey Flynn,

Really like the code you got, but I was looking to take it one step further if you could assist. For each tagged category I want to create a list of their recent posts. I've been messing around with and haven't figured it our yet, but I'm thinking it would be something like:

for each cat
do this
end foreach

Looking forward to hearing your thoughts.

Thanks
  #9  
Old Jan 4, 2010, 11:51 PM
Grant R Brown
 
2 posts · Jan 2010
Hey,

I was able to get it to work, here's the code in case anyone else has the same need:

Code:
<?php 
if (is_single( )) {
	$post_ID = $wp_query->posts[0]->ID;
	$all_cats_of_post = get_the_category($post_ID);
	for($i = 0; $i < sizeof($all_cats_of_post); $i++) { ?>
    
    	<li id="category-posts-<?php echo $all_cats_of_post[$i]->cat_ID; ?>" class="widget widget_recent_entries">
			<h3>Recently in <?php echo $all_cats_of_post[$i]->cat_name; ?>:</h3>
				<ul>
					<?php global $post; $cat_posts = get_posts('numberposts=3&category='.$all_cats_of_post[$i]->cat_ID); foreach($cat_posts as $post) : ?>
    				
                    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
					
                    <?php endforeach; ?>
                </ul>
		</li>		
        
	<?php } ?>
<?php } ?>
-Grant
  #10  
Old Apr 19, 2010, 09:15 AM
etripp
 
1 posts · Apr 2010
hi, i just found this forum via google, and it looks like you guys are trying to do the same thing i am.
i have a sidebar that i call on my category archive pages, and single post pages, that pulls in all the post titles from the 20 most recent posts.

it has a serious problem though. for some reason, when i include it, all post links, and all links within the sidebar link to the most recent post only, even though the urls are correct for each specific link.

perhaps someone know what i'm doing wrong.

here's the code for sidebarright.php

PHP Code:
    <div id="sidebarright">
        <?php global $post$categories get_the_category(); foreach ($categories as $category) : ?>
        <h3>Previous posts:</h3>
        <ul>
        <?php $posts get_posts('numberposts=20&category='$category->term_id); foreach($posts as $post) : ?>
        <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
        <?php endforeach; ?>
        
        <li>View the full archive for<a href="<?php echo get_category_link($category->term_id);?>" title="View all posts filed under <?php echo $category->name?>"> <?php echo $category->name?> &raquo;</a></li>
        <?php endforeach; ?>
    </ul>
    </div>
the site i'm working on is: www.lgtrippgallery.com

thanks!
  #11  
Old Apr 19, 2010, 09:54 AM
juggledad's Avatar
juggledad
 
23,765 posts · Mar 2009
OSX 10.11.5 WP 4.x Atahualpa(all) Safari, Firefox, Chrome
etripp, this forum is for the Atahualpa theme and you are not using it. If you decide to switch, feel free to ask questions here.
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support

Bookmarks



Similar Threads
Thread Thread Starter Forum Replies Last Post
Exclude category from Recent Posts in sidebar paulae Sidebars & Widgets 17 Apr 9, 2013 09:34 AM
Headline disappearing on single-post pages. Matt Butts New Versions, & Updating 6 Jul 11, 2009 10:15 AM
Footer on Single Post Pages > some of it is missing StudioGal Post-Kicker, -Byline & -Footer 10 May 8, 2009 01:31 PM
Static pages with category posts? mcphoto Atahualpa 3 Wordpress theme 3 Apr 25, 2009 10:48 AM
[SOLVED] How to show single post special category on static home page?? Shepherd Jim Post-Kicker, -Byline & -Footer 5 Mar 19, 2009 08:42 AM


All times are GMT -6. The time now is 10:21 AM.


Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.