• Resolved carolineh

    (@carolineh)


    Hi people, I’m currently putting together a theme that will function as a normal site (hopefully) with the main parts being a blog and an articles archive. I wanted to segregated the articles part and have done this to some extent by putting articles into a different category, created an index page for it and posts that exclude any of the blog content, have created a template for posts, single-3.php.

    But… On the blog index, which is fine, only shows blog articles, when I go to an individual post, single.php, I can’t stop the next and previous links from continuing into the articles posts.

    I can’t seem to find anywhere a way of excluding a certain category from the loop on single.php. Which leads me to think that I have to whole thing set up wrong in the first place. Is there a better way of running wordpress as a CMS, keeping content completely exclusive from each other. My idea was to use categories but think I’m barking up the wrong tree!

    Many Thanks, hope this makes sense, Caroline

    P.S. Sorry but I re-posted from ‘how to and troubleshooting’, realised after that it was probably the wrong forum.

Viewing 14 replies - 1 through 14 (of 14 total)
  • Try category templates rather than static pages: Category Templates ? WordPress Codex.

    Thread Starter carolineh

    (@carolineh)

    Hi Songdogtech, thanks for the suggestion. I have tried it out but it leaves me with the same results. I can only see the wanted categories on the right pages, but the previous and next links that are generated inside the loop

    <div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
    			<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    		</div>

    still display all of the posts, regardless of which category.

    Not really sure where to go from here, any suggestions?
    Thanks for the help so far!

    Something might be different with your main loop. Is it anything other than this?:

    <?php if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?>
    
    <a href="<?php the_permalink() ?>.....
    
    <?php the_content(); ?>
    
    <?php endwhile; ?>
    <?php else : ?>
    <?php endif; ?>
    
    <div class="navigation"></div>
    Thread Starter carolineh

    (@carolineh)

    No, it’s how it is,

    <?php query_posts($query_string . '&cat=-3'); ?>

    I added the above to the top of my category.php to stop it displaying items from category 3, and it does this just not for the navigation. I tried putting the navigation inside the endwhile tag but no difference.

    Really not sure, I was looking and saw the mention of adding to the functions.php, and this worked in the same way but didn’t stop the navigation.

    Cheers

    That’s the problem; use a standard loop and then category templates will work.

    Or use a variation of a new query on a static page with php execution enabled:

    <?php $my_query = new WP_Query('category_name=mycategory&showposts=5'); ?><?php while ($my_query->have_posts()) : $my_query->the_post(); ?><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a><?php the_content(); ?><?php endwhile; ?>
    Thread Starter carolineh

    (@carolineh)

    I don’t think I understand, where should I be using the standard loop and what do I put in the category template to cause the differentiation?

    Thanks

    Start with looking at the default wordpress theme and examine the standard loop and the php code that’s in it. You can’t break the rules of the loop and modify it without knowing the loop to begin with. And see: The Loop in Action ? WordPress Codex.

    Then work with Category Templates ? WordPress Codex for category pages that will, as a result, have previous and next links that work the way you want.

    Thread Starter carolineh

    (@carolineh)

    Then work with Category Templates ? WordPress Codex for category pages that will, as a result, have previous and next links that work the way you want.

    Could you point me towards some more specific documentation, I appreciate your help but I feel like I’ve already read through those and hundred other related pages inside out!

    Perhaps a tutorial on a similar topic, I can’t seem to find, or don’t exactly know what I’m looking for.

    Anybody reading this perhaps know what I’m talking about, please help ??

    I don’t know what else to tell you; that link above to Category Templates – and the link to The Loop – both do a good job of explaining how they work along with wordpress template files. Gotta read the docs.

    Thread Starter carolineh

    (@carolineh)

    Hi,
    I’ve semi-resolved this. Instead of segregating my sections through categories, I’ve used pages and sub-pages. This also makes styling my navigation easier.

    I am still puzzled by my original question, and it will probably crop up again in the future!

    I can’t stop the next and previous links from continuing into the articles posts.

    As far as I can tell, template tag, previous_posts_link() and next_posts_link(), don’t work that way.

    Thread Starter carolineh

    (@carolineh)

    Yeah, I think that I was wanting wordpress to do something it’s not really designed to do. So I’d probably need to set up a new blog database or something to avoid this? ‘cus what I want is really to completely separate 2 sets of content.

    Either that or consider a Related Posts type plugin.

    Thread Starter carolineh

    (@carolineh)

    Ok, thanks, I’ll bear it in mind ??

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘how to exclude one category from post links’ is closed to new replies.