WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Category page not being used (11 posts)

  1. Matt Hancock
    Member
    Posted 4 years ago #

    So I have a separate category page (category-3.php) to show items from the 'range' category (in this case, the ID is 3).

    However, WordPress is ignoring category-3.php and rendering the page using index.php instead.

    The contents of category-3.php can be viewed here and the header.php can be viewed here.

    Some help on this matter would be appreciated. :)

  2. design_dolphin
    Member
    Posted 4 years ago #

    The format your using in your naming of category-3.php should work.

    Are you sure it is not rendering index.php instead of category-3.php?
    You don't have a loop in your index.php, but do have one in category-3.php. Are you seeing any loop results?

    Sometimes a particular piece of code can mess up the loop and give unexpected results.

    Also I noticed your not using a query_posts, off the top of my head I can't remember if you need that, but try that or a basic loop in your category-3.php with query_posts.

    Otherwise a simple test I usually do with offline testing if for example something like this happens:
    Remove all content from category-3.php and back this up.
    Add just the plain word 'test' without any tags or markup in your category-3.php. And then see if you get the word 'test' in your browser screen when you go to view category 3.

    Also you could try using a basic theme that came with WordPress, to see if you can see category 3 there.

    Finally, are you using any plugins? One of these might be conflicting.

    Edit: corrected some writing mistakes.

  3. Matt Hancock
    Member
    Posted 4 years ago #

    Thanks for the reply.

    Firstly, it's rendering using index.php (which does have a loop in there). This was confirmed by doing your test.

    I did try putting a query_post loop in, but it made no difference. That code can be viewed here.

    I have no plugins installed.

    Something that someone did observe, however, was the file DID seem to work when I visited the /category/ URI.

  4. design_dolphin
    Member
    Posted 4 years ago #

    I read part of your first post wrong. No wonder your index.php didn't make sense... ;-) My apologies for that.

    Is the category rendering in the index.php or are you seeing the normal posts that you want to see in the index.php?

    Something that someone did observe, however, was the file DID seem to work when I visited the /category/ URI.

    Did it ignore the category.php? Do you have a category.php? (Not sure if it is needed.) Maybe it is jumping to index.php if there is no category.php?

    I did try putting a query_post loop in, but it made no difference. That code can be viewed here.

    What I meant was to put a basic loop in the category-3.php. Adding test in index.php, AFAIK, would not change anything as it would be overriden automatically by the category-3.php.

    For example in the code you posted I see this:

    <?php echo handle; ?>

    Is that correct? Shouldn't there be a $ in front of $handle?
    If so, there could be more mistakes in the code, which could be causing the problem.

    Are your Permalinks and .htaccess for the Permalinks set up correctly? How are you linking to the category 3?

    Are you having any problems for other URI such as single posts?

    Also check your server/ browser cache is empty, or make sure it is refreshing. This can sometimes be a problem as well.

  5. Matt Hancock
    Member
    Posted 4 years ago #

    Okay, the area in question can be viewed here. At the moment, it's not being linked to or from any other page.

    I don't have a category.php. All I have is

    • index.php - with a very simple loop
    • header.php
    • footer.php
    • category-3.php

    I don't have any other pages. I'm not sure if my .htaccess or Permalinks are setup correctly since I did all that through WordPress to begin with.

    I'm fairly confident that the site is refreshing - I tested the same page on Adobe Browserlabs with the same results.

  6. Matt Hancock
    Member
    Posted 4 years ago #

    I've just gone through and recoded the entire page with everyone in the one document. Code can be viewed here.

  7. design_dolphin
    Member
    Posted 4 years ago #

    In your development environment try the following:

    1. Activate the 'default' theme in your WordPress installation. It should have come with the download of WordPress.
    2. Create an empty category.php file with the content "Test plain category"
    3. Create an empty a category-3.php file with the content "Test category 3"
    4. Then go to the URI for category and category 3, and what are the results?

    In addition check the following both offline and online:

    Are you doing any URI rewriting in your .htaccess? Or in .htaccess in a folder higher up the directory structure? I noticed you are running the WordPress in a subfolder? Maybe something (in .htaccess) is conflicting?

    In your theme do you have any code in your functions.php?

    Are you sure the number of the category is 3?

    You need to find out what URI your category is on, and check your Permalinks with this, to make sure you are going to the correct URI, and you are using the same format in your URI as in your Permalinks.

  8. Matt Hancock
    Member
    Posted 4 years ago #

    Hi,

    When I go to http://wordpress.geek.nz/wakatapware/category/range/, I get the results of category-3.php. When I go to http://wordpress.geek.nz/wakatapware/wk2/, I get neither category.php or category-3.php

    My permalink structure is /%postname%/.

    Now all my categories have disappeared off the dashboard!

    Would be a good idea to just abandon this WP installation and start with a clean one?

  9. Matt Hancock
    Member
    Posted 4 years ago #

    I think I have this solved now...

    I ended up creating a single.php with the following:

    <?php
    $post = $wp_query->post;
    if ( in_category('3') ) {
    include(TEMPLATEPATH . '/range.php');
    } else {
    include(TEMPLATEPATH . '/single1.php');
    }
    ?>

    Basically, if the category is 3, then use the range.php as the template. Else, use the standard one.

  10. design_dolphin
    Member
    Posted 4 years ago #

    I think I have this solved now...

    I ended up creating a single.php with the following:

    <?php
    $post = $wp_query->post;
    if ( in_category('3') ) {
    include(TEMPLATEPATH . '/range.php');
    } else {
    include(TEMPLATEPATH . '/single1.php');
    }
    ?>

    Basically, if the category is 3, then use the range.php as the template. Else, use the standard one.

    Even though this works, I am not sure why. It is the incorrect way of calling a category.php.

    If you don't follow the instructions I give you, I really can't help you. I am not going to sit here and digest every bit of code you throw at me.

    Maybe somebody else can help you.

  11. cosmocanuck
    Member
    Posted 4 years ago #

    Hi!

    I'm also having the same problem as Matt and would like to fix it in the correct way, though am willing to try Matt's creative solution if nothing else works.

    My situation:

    - My permalinks are set to: /archives/%post_id%
    - The post in question is (definitely) in category 6
    - I made a template called "category-6.php"
    - When I access my post in question via this link:
    http://vineandfig.ca/archives/185
    ...I do not get the category template, just the "single" template is used.
    - Whatever I change my permalinks to, I still get the same problem.

    As for design_dolphin's list of things to check out:

    In your development environment try the following:

    1. Activate the 'default' theme in your WordPress installation. It should have come with the download of WordPress.
    2. Create an empty category.php file with the content "Test plain category"
    3. Create an empty a category-3.php file with the content "Test category 3"
    4. Then go to the URI for category and category 3, and what are the results?

    Since it's a live site I'm dealing with, I can't switch to the default theme. However I can confirm the following:

    In addition check the following both offline and online:

    Are you doing any URI rewriting in your .htaccess? Or in .htaccess in a folder higher up the directory structure? I noticed you are running the WordPress in a subfolder? Maybe something (in .htaccess) is conflicting?

    My .htaccess is modified since I'm also running WP in its own directory. But it's working perfectly in all other respects, and is modified the same way as on other sites I've set up this way (the exact same code in fact). So I don't 'think' it's to do with the .htaccess.

    In your theme do you have any code in your functions.php?

    I'm using the bare-bones functions file from the Classic template, and only added support for post thumbnails.

    You need to find out what URI your category is on, and check your Permalinks with this, to make sure you are going to the correct URI, and you are using the same format in your URI as in your Permalinks.

    I've listed this info above, and it seems to jibe.

    So... I'm kind of at the end of my rope here - why would the category template be ignored?

    Hope someone can help. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic