WordPress.org

Ready to get started?Download WordPress

Forums

Display by Category home.php template (52 posts)

  1. jeffd
    Member
    Posted 8 years ago #

    I'm working on a template that has two columns side-by-side each displaying the top posts from my two main categories. Your solution is the closest thing I have found & I really appreciate it, but I'm still not sure how to modify it to reach my design. I'm still an extreme novice at this - any input you have would be very appreciated. Thank you.

    http://www.jeffdomke.com - you can see the columns.

  2. ttiger
    Member
    Posted 8 years ago #

    For joelwalsh and those who want to create multiple categories with max n latest post for each on one page, you can find the way here http://infovore.org/archives/2005/04/12/multiple-loops/. It is also mentioned at multiple loop here http://codex.wordpress.org/The_Loop

    Hope this help!
    T Tiger.

  3. lricci
    Member
    Posted 8 years ago #

    I am using a WP 2 theme, and saw your note on the demo about experimenting with WP2.

    Has this file been tested for WP2.x?

    I'm a bit skitish about trying out files not so checked as:
    1) I'm a newbie, and
    2) the first time I downloaded and tried a file designed for WP1.5 it ditched my blog and I was in pretty bad condition for a week trying to resurrect my blog.

  4. Kafkaesqui

    Posted 8 years ago #

    The demo link in the first post is my test site, and it currently runs WordPress 2.0.2 with the specialized home.php template, unchanged since 1.5.whatever. Though the template is based on the default (Kubrick) theme, you should be able to mesh its workings into just about any layout.

  5. markgarrison
    Member
    Posted 8 years ago #

    Greetings,

    I'm completely new to this, but enjoying it.

    I've implented this on an index page, with some simple modification and now would like this format for archives by date as well.

    For example, when one would click on the archive by day -- using typoxp theme -- say May 28, one would see a similiar layout as on the index: every post posted that day would be presented under its category, not simply by time of day. I'm guessing this is easy to do, but when I looked at the archive.php page, and tried modifying the code, I only met with error! So, I'm hoping for help.

  6. Ryan Fitzer
    Member
    Posted 8 years ago #

    Excellent piece of work Kafkaesqui.

  7. seb
    Member
    Posted 8 years ago #

    This comes handy, thanks! But...

    Actually, the code above will correctly exclude one or more categories, but at the disadvantage of not displaying the correct number of posts per page. I'll have to look at the template's code and see what can be done through query_posts or whatnot to solve this.

    Is there a solution yet?

  8. moslemblog
    Member
    Posted 8 years ago #

    hi Kafkaesqui,

    I am really enjoying your hacking template here.
    However I have a question though, that maybe you can help me.

    In the sidebar :
    how can I show the category name followed by 3 (subheading) of posts title that linked to it's single page.
    How can I set the number of category shown, and the number of posts within that category shown ?

    I want my sidebar looks something like this :

    Category1
    >>title post1 in category1 (linked to its single page/post)
    >>title post2 in category1 (linked to its single page/post)
    >>title post3 in category1 (linked to its single page/post)
    >>title postn in category1 (linked to its single page/post)
    Category2
    >>title post1 in category2 (linked to its single page/post)
    >>title post2 in category2 (linked to its single page/post)
    >>title post3 in category2 (linked to its single page/post)
    >>title postn in category2 (linked to its single page/post)
    .
    .
    Categorym
    >>title post1 in categorym (linked to its single page/post)
    >>title post2 in categorym (linked to its single page/post)
    >>title post3 in categorym (linked to its single page/post)
    .
    >>title postn in categorym (linked to its single page/post)

    etc.

  9. moshu
    Member
    Posted 8 years ago #

    This "hack" and the whole thread is NOT about the sidebar - it is about the main page of your blog.

  10. flys
    Member
    Posted 7 years ago #

    Great code, i know this is what i'm looking for
    but i don't understand english well ... and neither php

    How can i do to display just the last post of each category ?

    thanks in advance

  11. ritalcnyc
    Member
    Posted 7 years ago #

    I am very new to word press, and to php.

    Would there be a way to adapt this template for a category-specific page so that it shows the sub-categories of the category page?

    For example, I have a category called Audio Archive and I have 5 sub-categories below it.

    TIA, Rita

  12. ritalcnyc
    Member
    Posted 7 years ago #

    I love the sort alphabetically, but my client wants an explicit sort (and I'm too newbie to figure out the explicit sort plug=in and adapt it). So...I've arranged it by category ID. Is there any way to get this to sort by category ID?

  13. lauch
    Member
    Posted 7 years ago #

    This is nifty! I actually might use parts of this for my dynamic category headings, though I'm not sure. It seems rather similar.

  14. StyleScope
    Member
    Posted 7 years ago #

    This was a perfect solution for my trouble (the first page of posts, that is. I needed a solution for showing posts from one cat, and excluding from another. Thanks! To show temp. results: http://www.jmstudio.nl -> look at the left block, only showing cat7 posts... GRRRREAT! :D

  15. CSSgirl
    Member
    Posted 7 years ago #

    Hi this is almost what I am looking for on a new project I am working on. But I have a question I only want 3 categories to display on the front page. So instead of excluding all the rest of the categories as someone asked before - is there a way to just include a few categories?

  16. Kafkaesqui

    Posted 7 years ago #

    "I only want 3 categories to display on the front page."

    For that I would recommend avoiding this template and sticking to using the tools WordPress already provides (it'll be less painful, trust me...).

    First, check out the info on query_posts():

    http://codex.wordpress.org/Template_Tags/query_posts

    If you don't need to segment your posts into discrete category listings, a simple:

    <?php query_posts('cat=1,2,3'); ?>

    should do (this will initialize your posts loop to display only posts from categories 1, 2 and 3). If you do need to break things up into different sections, then separate loops with query_posts() initializing each -- for each of your categories -- may be the way to go.

  17. CSSgirl
    Member
    Posted 7 years ago #

    Ah ok, I will have to look into it. I had initially asked about such a way to do it in this thread, and was directed here. The front page will have only 3 categories shown in a specific order. So I thought using some type of conditionals in the loop would help, but I am not quite sure exactly what code to use, and how exactly to format it.

  18. Kafkaesqui

    Posted 7 years ago #

    The goal behind my template here was to provide a solution to a very specific request in how to display blog posts on the home page, and that was by gathering current posts from a typical post loop and then listing them by category. There are ways to modify it to display only certain categories and whatnot (i.e. query_posts()), but in regards to your request, assuming I understand it fully, it lacks in a couple areas, primarily in setting up 'static' category sections on a page.

    If you have WP set to display the lastest 5 posts on the main (home) page, the template calls those 5 posts as normal. It doesn't concern itself as to which categories those posts are in until after it starts displaying them. We could certainly restrict posts to the categories you prefer, but if you want to assure exactly three categories are displayed at all times, the template fails you there.

    So, if you need 3 categories at all times with 1 or more posts under each, the use of conditionals and whatnot with a single standard post loop won't help you. Not unless you're bothering to make sure the current N posts are always in those 3 categories... That's why I believe setting up 3 different post loops with query_posts() initializing each (to define the category and post count for each) is your best option.

  19. akela
    Member
    Posted 7 years ago #

    Nice work! Is it possible to show one post as excerpt(or the whole post) and for others just titles(permalinks) under the same scenario - last N posts organized by categories?

  20. petrewp
    Member
    Posted 7 years ago #

    Hi,

    Excuse my poor english, but I'll try to explain my problem and needs.

    This plugin might be the one I need, but I've read through the thread but not become any smarter (not that I'm smart anyway), much because of my lack of PHP knowledge, but maybe more lack of knowledge of where goes what.. yep..

    P1. I want to have one post on the frontpage, only.
    P2. When I click a category, I want all the posts within that category to show on the following page

    Q1. How do I use this script for this (is there another that does this maybe, this might not be the one)?
    Q2. Should it be pasted in the index.php in the template folder?
    Q3. Which settings should then be used.

    Big thanks in advance,

    Petter / Norway

  21. Kafkaesqui

    Posted 7 years ago #

    akela, sorry for hitting your Q so late, but sure, why not? :)

    All you need is to perform a test against a PHP variable that ticks off or iterates for each post within a category, but resets at the start of the next category.

    petrewp,

    First, this is not a plugin. It's important to keep that in mind. Now...

    P1. Then this template is not for you.
    P2. WordPress nearly provides this, as they say, 'out of the box,' though it does require a bit of help if you want one post on the home page but *all* posts in a category on just one page.

    I'd look at this plugin, which deals with both your P's:

    http://mattread.com/projects/wp-plugins/custom-query-string-plugin/

  22. petrewp
    Member
    Posted 7 years ago #

    Kafkaesqui,

    Big thanks, the plugin from mattread was exactly the thing I needed.

    Cheers,

    Petter / Norway

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags