• Hello! I am doing 5 different pages. On each page I want the posts of the respective to show.

    Example:

    If I have “Animals” I want all posts in the category “dog” do be displayed there and only there.

    Then I have say bears and want “grizzly” to display only there.. How would I go about?

    Thanks

Viewing 15 replies - 1 through 15 (of 16 total)
  • Thread Starter romeon

    (@romeon)

    No one?

    I just did something similar to this. Let me figure out how to explain what I did…

    [signature moderated]

    MAKE SURE you keep backup files before you start editing code!!

    Ok. It’s really fairly easy.

    I created a “Blog” page template from the original main template file. copy, paste, rename, however. don’t forget to rename it Blog Template inside the php file.

    Within that file in the correct place (you’ll have to determine where the correct place is per your theme), I placed the following code. Then created a page for each category so it will have a place on the menu. Each of those pages will use the Blog page template instead of the Default page template.

    Finding the correct place in your template is trial and error if you are not familiar with php code.

    THEN in the following code, you must enter the corresponding page number to the category. Make sense? Each page you create has an ID number as well as each category you create has an ID number. If you need to add more than three, just copy/paste the elseif line and change the numbers to correspond.

    You’ll likely be able to find better explanations on this by just googleing some of the following code. I cannot find the bookmark of where I first came across it.

    edit the last part as you need. classes may be incorrect for your theme and you may wish to have different info in the byline.

    ****************************************************

    [code moderated – please use the pastebin]

    *****************************************

    reading your question again, I wonder if you want page Animals to show category dogs, page Bears to show category grizzly’s, but then what if you want to add category Black Bear to the page Bears….?

    This code can likely be manipulated to do that also… maybe commas in the category line…

    Thread Starter romeon

    (@romeon)

    Perfect! Thanks a million, as I was searching I also came across this plugin:
    http://wordpress.org/extend/plugins/list-category-posts/

    Thread Starter romeon

    (@romeon)

    Ok that didn’t help me.

    I got 1 category / page. I want it do display ONLY the category related to it.

    Here is the loop code in the theme. How would I go about to persay only display category with ID 1 in this loop?

    [code moderated - please use the pastebin]

    Ahhh.. the loop. I think you wanna skip the loop all together. Your Blog template page should be totally different. The loop is in the code I posted earlier.

    Here’s my index.php:

    [code moderated - please use the pastebin]

    See how it go get's the loop and runs it? similar to your loop.

    Here's my blog-template.php:

    [code moderated - please use the pastebin]

    It has it's own loop, so as to not call the theme loop.

    See http://mercyhillblog.com On the menu, I'm calling each category into it's own page. Mercy Hill Blog, Manns' MC and Young's MC Each of these pages show posts separated only by category.

    WP knows when Manns' MC is selected, it runs the blog template and sees that it is page 19 so it posts all category 4 posts. When Young's MC is selected, it runs the blog template and sees that it is page 21 so it posts only category 5 posts.

    So I'm thinking, find your index.php copy it to your blog template (blog.php or whatever) and replace the section where it calls the loop.php with the first code I pasted above.

    May I ask what is the name of the base theme you are using?

    OK. This is TOTALLY a test page. Pay no attentions to content you may find there… It’s where I test many themes and plugins.

    This theme is based on WP twentyten with lots of mods…

    http://upstairsroom.net/test

    Animals = dogs
    Bears = grizzlys
    Blog = all

    simply by changing “this page = this category” in the code.

    or you could do “Pets” category that could include cats, dogs, birds, etc. and a “Predator” category that would include bears, wolves, lions, etc… IE – broaden the categories.

    I’m gonna actually play with this script to see if you can post two or more categories (but not all) onto any give page… for my own use.

    It works as a combo also by adding the comma between the category ID numbers.

    I just noticed that the WP menu also allows you to add categories to the menu, but the page layout looks different when they show…

    Thread Starter romeon

    (@romeon)

    Thanks a million. That’s the thing though, I want the page to display just as my index.php i displaying it, however depending on category.

    The site I am making is only going to have 1 category page..

    Let’s me start from begging cause Im confusing you and my self πŸ™‚

    I want my index (looks almost like yours, it calls the loop.php)
    The loop.php is where it displays my index.php I reccon.

    What I want is the exact same look. How my index.php is displayed. However, depending on the page it’s on (I guess using if is_page(‘id’)) i want it to display a certain category.

    I dunno if you understand me πŸ˜›

    Yeah, I THINK I understand.

    You’re correct. The index is the main page layout. It calls the loop. The loop gets the info and puts it on the screen.

    The blog template will look just like the index when it writes to the screen (ideally – but it will likely take some tweaking), but your loop is built into the blog template code instead of being called from an external file. (you can actually set it up to call externally, but it’s easier I think to code it directly in the page.

    I feel I must interject here that I am not a professional. This is all learned from hundreds of hours of trial and error over the last several years.

    I’m currently stuck on a plugin project on the mercyhillblog.com site and awaiting help from this forum so I’m in-between projects you might say.

    I’d be happy to give it a shot for your theme if you’d like. If I can download your theme from WP or elsewhere. or you can upload it to via FTP. I’ll play with it to see what I can get it to do.

    Again, I’d be glad to help, but I need the theme.

    Or you can tell me to bug-off and leave you alone. That’s understandable also! πŸ™‚

    Question: if this is to be done through code and not hard-coded into the page template, how will you establish a link between (say) Page A and Category B so that WP “knows” what category to query? Once that logic is sorted, it seems to me that it’s just a page of posts.

    it is “hard coded” into the page template… or as the WP “loop page” goes, it’s hard-coded into the loop template and then called into the page template…

    Actually, it’s hard-coding it into the blog template, blog.php (edited clone of index.php)

    When you create a page, you choose the blog template instead of the default template for those special pages only. All others use the default template…

    Hope that makes sense…

    see the links to pages above to see it work.

    Thread Starter romeon

    (@romeon)

    I can’t as it’s not my website and it’s a paid theme so when I asked the owner she said rather not send the theme. Sorry man.

    I am so clueless. I have no idea how to get it to work. Tried everything, been googeling for 2 weeks. Nothing.

    All I know is that if I modifie the loop.php which I showed above I’d be able to use condtional tags and make it work. But the questen is, where to alter the code so it shows only a specific category?

    Any luck yet?

    Still willing to help…

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Each page displaying a category?’ is closed to new replies.