WordPress.org

Ready to get started?Download WordPress

Forums

what dictates the category the main index file is assigned to? (13 posts)

  1. e7
    Member
    Posted 7 years ago #

    I'm trying to figure out how my index.php file for my main wordpress loop got assigned to a sub category I have on my website.

    Is it the biggest number of posts which dictates dynamically what category is assigned to the main loop?

    I started off designing a theme which is visible at:

    http://e7.shanky.com/

    Then later on I made a new sub theme for the subspace category which I get a lot of users on for my site.

    http://e7.shanky.com/wordpress/?cat=4

    Today I realized the main loop is also using this category which I don't want... this is visible here:

    http://e7.shanky.com/wordpress/

    Any ideas? How can I assign which theme my main loop uses?

  2. e7
    Member
    Posted 7 years ago #

    Bump, no replies?

  3. Joshua Sigar
    Member
    Posted 7 years ago #

    Sorry, Got no time to explain right now. In the meantime, read this up
    http://codex.wordpress.org/Template_Hierarchy

  4. e7
    Member
    Posted 7 years ago #

    alphaoide,
    I've read through a bunch of that, I tried to find an answer there but nothing jumps out. I might have an answer through. I have the Subspace category selected as my default post category, could that be the reason why this category is being used by the main site?

  5. e7
    Member
    Posted 7 years ago #

    Still no resolution to this?

    Can someone please give a quick answer which is simple to understand? Thanks!

    Like yes: the category with the most posts is the one used by the main loop.

    A possible hit of where in the code to look for this would be even better, thanks.

  6. moshu
    Member
    Posted 7 years ago #

    Unless we know more it is difficult to guess. Are you using some kind of conditional tag in the header or are you just using a special category template? Both?

    Maybe if you post the code snippet that selects the stylesheet...

  7. e7
    Member
    Posted 7 years ago #

    Hey Moshu, thanks for responding again, I am using conditional tags in the header and all over the place actually. I just now determined that the main loop takes the category of the latest post automatically, I was thinking that's an optional selection logic.

    Can someone point me to the code which decides this? Now that I know what it is maybe I can find it for myself, I'll post here when I get some time to look through it.

  8. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    e7: Without knowing what the heck you did, it's impossible to tell you what to do. We deal in specifics here, not generalities.

    Like this:

    Then later on I made a new sub theme for the subspace category which I get a lot of users on for my site.

    How, EXACTLY, did you do that? Post the relevant code snippets. Everything depends on what the heck your theme is doing, and until we know that, there's no real way we can tell you anything that you would find helpful without doing a total brain dump of everything we know. And frankly we don't have that kind of time.

    What does your main loop look like?
    How did you make this "subtheme"?
    What plugins are you running?

    You have to explain what you're talking about in order to get relevant answers. We are not mind readers.

  9. e7
    Member
    Posted 7 years ago #

    Oh wow, relax buddy, it is exactly as simple as stated. I have made NO alterations to the wordpress code except to add a snipped which allows me to change page categories but that has nothing to do with the question I posed.

    My website has TWO themes, a main theme and a theme which shows when posts/pages belong to the Subspace category. It is a template or a theme like any other.

    I have made NO alterations to the main loop.

    This is obviously something which I will have to resolve myself though, like the page categories topic, because it is obviously too complicated for you guys to figure out even though I find it surprising and I don't think the setup I'm running on my site is complicated at all. The conditional tags I'm using are strictly to display each theme properly because of how I'm displaying the header mainly but there are tags which check the category outside of the header too, all those tags are intended for is to display each theme correctly.

    The question I posed was simple: what dictates the category to the main loop?

    Somewhere, in the main loop, a category is assigned to the loop itself. When I first asked the question I didn't know what caused the particular category to be selected, I've now figured that part out. It appears that the decision is made based on the latest post, I found this out recently when I posted something in a category different then the Subspace category, the loop then was using the main theme. Anyways, when I have time to troubleshoot it and resolve it I'm going to post here.

  10. Chris_K
    Member
    Posted 7 years ago #

    The question I posed was simple: what dictates the category to the main loop?

    I assume you're referring to The_Loop running on your blog's index.php? It doesn't give a flying fig about your categories unless you've coded it to (by modifying The_Loop in index.php, for instance).

  11. moshu
    Member
    Posted 7 years ago #

    Well, let's calm down, if it's possible.

    e7, you are introducing non-standard notions (terminology), like "sub-theme" - which confuses everybody. If you changed the standard behaviour of the theme-selection/display mechanism, let us know.
    If you are just using a Category Template, then call it like that.

    Furthermore, for the catgeory conditionals, there are two variants:
    in_category
    is_category
    They don't behave the same.

    And finally, inserting is_home in the conditional code will make sure that the index/main page will use whatever design you assign to it.

  12. e7
    Member
    Posted 7 years ago #

    Ah moshu that was a bit more helpful. I'm using some of these conditional statements in the header to determine what category each post/page belongs to. I'm not familiar with is_home tag but I'll take a look into it.

    I am using a particular theme to display one of my categories. I want this theme to only display in pages/posts and the category-4.php files, and I don't want it to show up in the index.php file.

    Yes, I'm referring to the index.php file in the WP directory.

  13. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    Ahh. You'll want to read this then:
    http://codex.wordpress.org/Conditional_Tags

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags