WordPress.org

Ready to get started?Download WordPress

Forums

Using query posts in seperate single.php templates (4 posts)

  1. phejster
    Member
    Posted 6 years ago #

    I'm working on a custom theme for my site and have set up 2 custom single.php templates. In both of the templates I'm using <?php query_posts('cat=ID'); ?> where ID is either the only category that I want or the category that I want to exclude.

    It's working on the homepage, but the single.php template now just shows all the posts that match that criteria. Is there a way to do this?

  2. phejster
    Member
    Posted 6 years ago #

    Ok, I think I've figured out most of it. What I'm basically trying to do is have one section of my site have only posts from one category and the rest of the categories in another section. I used the 'Unique Single Template" hack from this page (http://www.webdesignerwall.com/tutorials/wordpress-theme-hacks) to split off the two sections.

    Category ID 3 is the one I want on it's own and I have it working now by changing the default previous_post_link to the following <?php previous_post_link(<strong>Previous Entry</strong>%link', '%title', TRUE, ''); ?>.

    However, in the catch all template I have replaced the previous_post_link with <?php previous_post_link('<strong>Previous Article</strong>%link', '%title', FALSE, '3'); ?> but it's not working and still linking to posts in category 3.

    What am I missing?

  3. phejster
    Member
    Posted 6 years ago #

    Does anyone have any ideas why the previous_post_link isn't restricting the category I have specified? I've tried everything I can think of and been all over the forums but have found nothing.

    <?php previous_post_link('<strong>Previous Article</strong>%link', '%title', FALSE, '3'); ?>

  4. piechdibi
    Member
    Posted 6 years ago #

    I guess that instead of FALSE, you should have TRUE...

Topic Closed

This topic has been closed to new replies.

About this Topic