WordPress.org

Ready to get started?Download WordPress

Forums

category template not working (15 posts)

  1. BSK
    Member
    Posted 2 years ago #

    hi all,

    i've setup 2 category templates based on the info in the codex. one of them works fine, but the other just shows my 'not found' message.

    i've created these based on category slug, and double checked to make sure the slugs are correct.

    category-case-studies.php
    category-tech-blog.php

    The case studies one works fine and shows an archive of my posts in that category, but the tech-blog one shows 'not found'. i have 2 posts in the tech-blog cat, and i can view them just fine when previewing the individual posts (i'm using a cat single post template - single-tech-blog.php).

    I've even tried pasting all my code from category-case-studies.php into category-tech-blog.php and it still doesn't work.

    what could i be doing wrong?

    thanks!!

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    Are both posts in the top level tech-blog category? Are are they in a child category?

  3. BSK
    Member
    Posted 2 years ago #

    thanks for getting back. both posts are in the top-level tech-blog category.

  4. BSK
    Member
    Posted 2 years ago #

    fyi - the page is showing my 'not found' message that's in my template, NOT my 404.php just to be clear. thanks!

  5. esmi
    Forum Moderator
    Posted 2 years ago #

    the page is showing my 'not found' message that's in my template

    Would that be category-tech-blog.php? If so, have you tried dumping the $query object to the screen to see what is actually being called from the database?

  6. BSK
    Member
    Posted 2 years ago #

    Would that be category-tech-blog.php?

    Yes

    If so, have you tried dumping the $query object to the screen to see what is actually being called from the database?

    No. How can i do this?

    Thanks again!

  7. esmi
    Forum Moderator
    Posted 2 years ago #

    Try adding:

    <?php echo '<pre>';
    print_r($wp_query);
    echo '</pre>';?>

    just before the start of the Loop.

  8. BSK
    Member
    Posted 2 years ago #

    thanks. a lot of things appear. is there something specific i should look for?

    this shows at the bottom.

    [queried_object] => stdClass Object
            (
                [term_id] => 43
                [name] => Tech Blog
                [slug] => tech-blog
                [term_group] => 0
                [term_taxonomy_id] => 44
                [taxonomy] => category
                [description] =>
                [parent] => 0
                [count] => 2
                [cat_ID] => 43
                [category_count] => 2
                [category_description] =>
                [cat_name] => Tech Blog
                [category_nicename] => tech-blog
                [category_parent] => 0
            )
    
        [queried_object_id] => 43
    )
  9. esmi
    Forum Moderator
    Posted 2 years ago #

    Can you see the content for the two posts in that query dump?

  10. BSK
    Member
    Posted 2 years ago #

    hi there - no, I don't see the actual content anywhere in the query dump.

  11. BSK
    Member
    Posted 2 years ago #

    any guesses on what could be causing the content not to appear? thanks again for your help!

  12. esmi
    Forum Moderator
    Posted 2 years ago #

    Drop a copy of the file into the WordPress pastebin and post the pastebin url here. Perhaps someone will be able to spot the problem and suggest a solution.

  13. BSK
    Member
    Posted 2 years ago #

    Ok, the pastebin url is here.

    Thanks!!

  14. esmi
    Forum Moderator
    Posted 2 years ago #

    That looks fine. Perhaps there is something in header.php or functions.php that is causing a problem?

  15. BSK
    Member
    Posted 2 years ago #

    it's weird because i have another category template that is working just fine. I've looked at the php files and they're the same - only difference is the filename (category-cat-slug.php).

    i did see a thread about duplicate cat slugs causing conflicts. i reviewed my slugs and there are no duplicates.

    thanks again for you time!!

Topic Closed

This topic has been closed to new replies.

About this Topic