• Hello,

    I am trying to get a list of posts from a certain category to display in my sidebar. I have followed all of the previous discussions and the examples in the codex. It works great on my index page, but when i go to a single entry the sidebar suddenly doesn’t list them. For testing purposes I have made my single.php have exactly the same code as my index.php. Any ideas why it would work in one and not the other?
    currently it is a loop within a loop. perhaps this is not necessary.

    here are the various codes i’ve tried in my sidebar, both work on the index page, but not on the single.php:
    1.
    ‘<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php query_posts(‘category_name=projects&showposts=27’); ?>
    <?php while (have_posts()) : the_post(); ?>
    “><?php the_title(); echo “
    “; ?>

    <?php endwhile;?>
    <?php endwhile; else: ?>
    sorry, no projects entered yet.
    <?php endif; ?>’
    2.
    ‘<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php if ( in_category(‘2’) ) { ?>
    “><?php the_title(); echo “
    “; ?>

    <?php } else { ?>
    echo “tart”
    <?php } ?>
    <?php endif; ?>’

Viewing 15 replies - 16 through 30 (of 32 total)
  • Thread Starter poultryfarm

    (@poultryfarm)

    sorry for the confusion. the rest of the “content” isn’t there because i am really trying to isolate this problem. so yes i took out the content in the main areas, i.e. it’s normal that there is a lot of white space. agaiin I just wanted to bare down the code to isolate this problem to make sure it wasn’t anything else that was messing it up.

    Thread Starter poultryfarm

    (@poultryfarm)

    moshu, those are exactly the links you should be seeing! those are the project names i described above. when you click on those you get to the project page where the same list of project names should appear, but for some reason it’s only working correctly on the index page.

    Thread Starter poultryfarm

    (@poultryfarm)

    arlo, thanks for the link. But, i’m not using any coppermine plugin code. the sidebar code really only consists of the code i mentioned aboveâ€â€?again i’m really trying to isolate this problem so i’ve stripped everything else out. I’ve tried with all plugins off as well, same problem.

    When I click on any of those links – they all disappear… and in the middle of the screen there is a tiny “test” text.
    Which theme did you start off when building your theme? Is there any if statement in your header.php template?

    Ah ok, sorry for the confusion! 🙂 As I said above, I am only seeing one of the items, due to the page not scrolling up high enough. As for why they aren’t showing… do you have a single.php and does it include a call to get the sidebar? Are those just recent posts? Why not just use a Recent Post plugin?

    PF, I am using Firefox on a Windoze box. Here are the results when I click on the links from your main page:

    # avery –> blank menu area
    # beirut –> blank menu area
    # amy lipton gallery –> Truncated link that says “GALLERY”
    # the london project –> Truncated link that says “PROJECT”

    So it halfway links to two of them. What should be happening, if I understand you correctly, is that if you click on ANY of the links, they should ALL still appear on the sidebar.

    Thread Starter poultryfarm

    (@poultryfarm)

    jonimueller,
    yes you understand me correctly, all of the link should still appear on the sidebar. the basic idea is that the project title that you are currently viewing will be highlighted in a different color (or underlined, styled differently from the rest) than the rest of the project titles. but all should still be visible and clickable.
    interesing that you get different results than i do. i’ve tried on both a mac with safari + firefox and on windows using firefox and get the same results:
    # avery –> avery
    # beirut –> beirut
    # amy lipton gallery –> amy lipton gallery
    # the london project –> the london project

    Thread Starter poultryfarm

    (@poultryfarm)

    moshu,
    sounds like you are experiencing the problem. the titles should still be listed on the right sidebar just like they are on the index page. the “test” that appears is good and is just a filler for some content for that project.
    I really started with a clean slate and pulled and inserted code based on the articles in the codex and at times from code from the default theme. but all in all there is not much php in my theme yet because i’ve really just been trying to get this part to work!

    What resolution is your monitor? (I am using standard 1024×768.) I’m wondering why the last two links I listed were truncated. I mean, I think the amy lipton gallery link should SAY amy lipton gallery, not “GALLERY.” Same for the London Project. Weird.

    code from the default theme

    That’s exactly why I was asking this question 🙂
    That theme has a lot of if-stuff in the header; like: if single do not show the sidebar…

    Thread Starter poultryfarm

    (@poultryfarm)

    – no if statement in my header.php
    – my single.php is exactly the same as my index.php (thus my confusion as to why it is displaying differently).
    – i’m not using a recent post plugin because i want to exlude certain categories from this list. for example i have a news section (as well as other categories) that should not be a part of this project list. But i’m certainly open to using a plugin if it will help me achieve this. perhaps I am going about this in a backwards way? i don’t think so though.

    Okay, I changed my monitor resolution to 1280×960 and MORE LINKS appeared above the ones already there. And the London and Amy Lipton links were NOT truncated any longer. They each only link to themselves. But that is some headway. Odd nonetheless.

    Thread Starter poultryfarm

    (@poultryfarm)

    my mac is at 1280 x 854
    and my pc is at 1680 x 1050
    yes strange that it truncated the names, but good to know, that will certainly not be acceptable for people with smaller screens. you think that is the problem? but the css should still display normal and you would need to scroll. i don’t see why anything would be truncated because of a smaller screen.

    If your single.php is the same, why not just use the main template. You don’t NEED to have a separate template for individual posts. Try deleting it (or renaming it without the *.php extension so WP can’t find it) and see if that makes a difference. Because then, you’d be running the indiv. entries off the main template, which you know already works fine.

    Thread Starter poultryfarm

    (@poultryfarm)

    oh man. thanks mueller. again this seems strange to me, but good to know as i’ll have to work around this for people with smaller screens.

Viewing 15 replies - 16 through 30 (of 32 total)
  • The topic ‘sidebar code working on index but not on single template’ is closed to new replies.