Support » Plugins and Hacks » Blog in Blog Problem: Authors Post Link

Blog in Blog Problem: Authors Post Link

  • I’ve made a small hack for my sidebar in order to show the recent 3 posts under my cathegory-links with a small loop outside the Loop:

    $posts = get_posts('numberposts=3&offset=0');
    foreach ($posts as $post) :
    <h3><a href="<?php the_permalink(); ?>"><?php the_title() ?></a></h3>
    <p><?php the_excerpt() ?></p>
    <div><?php the_time('d.m.Y H:i'); ?> | <?php the_author_posts_link('nickname'); ?> <?php comments_number('| 0','| 1','| %'); ?> | <a href="<?php the_permalink(); ?>">more</a></div>
    <?php endforeach; ?>

    Of course the_author_posts_link does not work correctly, because it always is relating to the “Main-Loop”. Do I have any chance to show the author relating to the post-excerpt inside this second loop?

Viewing 5 replies - 1 through 5 (of 5 total)
  • I’m not sure I understand. How exactly is the_author_posts_link() *relating* back to your regular post loop?

    Sorry that this was not clear, because of my poor understanding of WP and my bad English…

    I’m using WP generally to present static informations, that are shown as single posts – each in a category of its own. Beside this there is the blog. The sidebar containing the recent three posts from the blog is shown in both, the static information and the blog.

    So, if one is reading a post of static information, the small loop above will identify each ” the_author_posts_link” depending to the post, that is containing the sidebar. The author will always be the same and not the one, that it should be correlating to each post’s excerpt of my sidebar-loop.

    Sounds cruelly, i know 😉

    Your English is fine; I just wasn’t sure about what was occuring. Most likely the post data is not being called up completely through get_posts() (as happens when you use the_content() with it). Try adding a call to setup_postdata() in your code in the foreach:

    $posts = get_posts('numberposts=3&offset=0');
    foreach ($posts as $post) :

    Kafkaesqui, your advice was the answer to my problem. The sidebar now is working well. Many thanx & be blessed!

    New problem using permalinks?
    As I mentioned before, my site is prevailing using singleposts for each category. Now, if there are more posts assigning to a category inside my blog, WP is creating a dammed postslug of its own for each of those posts. For example, the link to the second post within my blog’s category “support” is shown as “http://blog.org/2005/06/14/support-2/”. This link shows me an 404 Error. Inorder to reach that, i use the following code inside the small Loop from above:
    <a href="<?php the_permalink(); ?>"><?php the_title() ; ?></a>
    On the whole site permalinks are working fine, as long as there is only one post assigned to a category.
    I’ve really no idea, where this might be substantiated…

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Blog in Blog Problem: Authors Post Link’ is closed to new replies.