ThemeShaper Forums » Thematic

[closed]

How can I show different categories on different pages?

(26 posts)
  • Started 4 years ago by anthony99
  • Latest reply from anthony99
  • This topic is resolved
  1. anthony99
    Member

    Hello, I would like to be able to show different categories on different pages of my blog.

    Let's say my blog is about cooking. I have a post titled "Italian Food Menu Plans." Then I have categories down the right side of Thematic as follows: "Lasagna dishes," Tortellini dishes," "Spaghetti dishes," etc.

    The next post is titled "Mexican Food Menu Plans." I want to list categories on this page like "Tacos," Burritos," "Enchiladas," etc.

    How can I accomplish this in Thematic? I am not using a child theme and want to make changes to the code directly. I very much appreciate any help someone can provide.

    I have also looked at this plugin, not sure if it will do the job or not?

    http://categorypageextender.wordpress.com/

    Posted 4 years ago #
  2. @Anthony99: You could consider using Categories for the main content.

    - Italian Food Menu Plans
    -- (subcat of Italian Food) Lasagna Dishes
    -- (subcat of Italian Food) Tortellini Dishes
    etc.

    Then you could use a widget to display subcategories. One widget that looked useful is Extended Categories Widget as one of the features is

    A Category Group widget. Shows categories from a group which is associated with the post/page that the visitor is looking at. Categories can be added to a group. Multiple groups can be made and every post/page can be associated with a different group. This requires WordPress 2.8 or higher.

    And then youc ould use e.g. Widget Context to set that this widget should only show when browsing categories.

    On another note, why not use a child theme? It's really simple to setup as you just edit the files in the 'sample' folder included in the Thematic download.

    This explains it well: http://www.catswhocode.com/blog/wordpress-how-to-easily-create-a-thematic-child-theme

    Posted 4 years ago #
  3. I would recommend http://wordpress.org/extend/plugins/slayers-custom-widgets/

    Posted 4 years ago #
  4. anthony99
    Member

    I appreciate the feedback, it seems like this should be a simple thing to do. Is there any way to change the code itself rather than use a plugin?

    Again, for example I make a post on "Mexican Foods" and want categories relating to ONLY Mexican foods showing on this page. Next post is on "Italian Foods" and the categories shown on this page relate ONLY to Italian foods.

    Sorry if I am a slow learner here!

    Posted 4 years ago #
  5. @Anthony99: I think you're right there. In my simple mind, a custom sidebar is probably the way forward.

    This post by Michael H looked very promising:
    http://wordpress.org/support/topic/287664?replies=6#post-1132717

    and it may need some slight adaptation for Thematic/more recent versions of WordPress.

    Hope this is more helpful than my last post. I clearly love Widget Context ;)

    Posted 4 years ago #
  6. anthony99
    Member

    Flick, tell me more about Widget Context and how it might be applied to my situation.

    Thank you.

    Posted 4 years ago #
  7. @anthony99: In hindsight, it would probably be more straightforward to just go with the custom sidebar than to go with a plugin.

    Not sure if you'll be using a page or a post for "Italian Food Menu Plans." which I guess maybe an introduction to the nature of the food plan.

    So :
    Italian Food Menu Plans

    Lots of Lorem Ipsum here introducing the basics of the Italian Food Menus.

    And on the right hand side you want to display categories - which you can do so by using a custom sidebar. Or if you wanted to use a simple 'Text' widget and manually add in the Categories, you would create one that had links to the food categories:

    "Lasagna dishes," Tortellini dishes," "Spaghetti dishes,".

    If using Widget Context, you could set it so the widget *only* shows up for the Italian Food Plan page and on any posts within Lasagna Dishes, Tortelini dishes etc.

    Then you could create another text widget but with links to Mexican food categories and do the same thing.

    Of course, there are widgets that can automatically find and list subcategories.

    Hope this attempt at an explanation is better?

    Posted 4 years ago #
  8. anthony99
    Member

    Hi flick

    Thanks for trying to help me, I really appreciate it. I am still a struggling techie, so if you could bear with me and walk me through the process, I would be very grateful!

    The way thematic works now is that if I make a post entitled "Italian Food Recipes," and then add the categories "Lasagna Dishes," "Tortellini Dishes," etc, those categories will appear on the right side in addition to ALL categories from PREVIOUS posts. So if I wrote a post entitled "Mexican Food Recipes," a month ago, and added the categories "Burrito Dishes," Taco Dishes," etc, those categories will ALSO appear in the categories listed down the right side. I don't want that - instead I want the categories showing on each post (I have set my blog to show one post per page) to be EXCLUSIVE to that post and to show on that page only.

    I thought perhaps there would be a way to change the code itself so that whenever I choose categories for a particular post, they would show on that post's page only. Then it was suggested to try a plugin, so I have tried the Extended Categories Widget plugin and also Slayer's Custom Widgets plugin, but neither one seems to do the job.

    If there is another way, and if you could explain it to me as if I were 7 years old, I would be happy to try it.

    Thanks very much, and I apologize for my lack of tech expertise!

    Sincerely,
    anthony99

    Posted 4 years ago #
  9. Hi anthony99,

    Are you saying that your blog/home page is set to only show one post at a time. And you want a widget in the sidebar that only shows posts from the same category when on that page?

    -Gene

    Posted 4 years ago #
  10. anthony99
    Member

    Hi Gene

    Yes, my blog is set to show only one post on the front page. Previous posts all have their individual pages as well. Basically, I want each blog posting to be "independent" of the others. Whenever I add a new post, I hope to be able to choose what categories I want to appear down the right side for that post (and that post only).

    The key point here is that I want to have complete control over what categories show down the right side for each individual post.

    Posted 4 years ago #
  11. Sorry to drag on like this, I'm just trying to frame the question in a way that I understand what you're wanting to do.

    1. You want a list in the sidebar (widget?) that only shows a category listing of all the categories assigned of the single post displayed on a paginated blog/front page set to only show one post per page .

    -Or-

    2. Do you want a widget in the sidebar that lists related posts from similar categories as the one post shown on the paginated blog/front page set only to show one post at a time.

    Either way I'm not immediately seeing a detailed answer but framing the question well is a good start to solving any problem.

    Posted 4 years ago #
  12. anthony99
    Member

    Hi Gene

    I want to do #1 above. Here's an example:

    BLOG TITLE: Delicious Food Recipes URL:DeliciousFoodRecipesDOTCOM (example)

    First posting (only one post per page)
    "Italian Food Recipes" ------------------------------------
    ------------------------------------------------------------CATEGORIES
    ------------------------------------------------------------"Spaghetti"
    ------------------------------------------------------------"Tortellini"

    Next posting (again, one post per page)
    "Mexican Food Recipes"--------------------------------------
    ------------------------------------------------------------CATEGORIES
    ------------------------------------------------------------"Tacos"
    ------------------------------------------------------------"Burritos"

    What I want to be able to do is dictate what appears on the right margin in "Categories," so that each post only shows the category or categories that I have assigned to that one specific post.

    I hope it's clear, sorry to go on so long.

    Thank you very much.

    Anthony99

    Posted 4 years ago #
  13. @anthony99: I'm 100% certain that em hr will offer you some very good advice, but personally, now I wonder if tags are more appropriate for your project?

    So: Mexican Food Recipes (I am still not clear what content is here. Is this a recipe?) page/post, you can assign tags to the post at the very least.

    Then your sidebar/widget will simply display the tags pertaining to that post, which in this case will be Spaghetti" and "Tortellini".

    If someone then clicks on 'Spaghetti', they will see a list of posts that also have 'Spaghetti' as one of the tags.

    Posted 4 years ago #
  14. anthony99
    Member

    My purpose is SEO optimization. The default setting for thematic show all the categories on each page. I only want categories relevant to each type of food to show on each page. That way the search engines will have an easier time finding each page individually, rather than always going to my home page.

    Surely there is a bit of code that can be modified to accomplish this?

    Posted 4 years ago #
  15. I think hunting around for a plugin would be the best solution for this. Perhaps Query Posts combined with Widget Context or Widget Logic?

    Posted 4 years ago #
  16. Hi,

    the code basics for the sidebar are explained here: http://yoast.com/showing-subcategories-on-wordpress-category-pages/

    Chris

    Posted 4 years ago #
  17. anthony99
    Member

    Ian and Chris, thank you for replying. If I make changes to the code as instructed, how can I tweak it so that rather than it being a subcategory, it is simply a category? At the end of the day, the issue is simple: I want each posting to stand alone, independent of the others. That means that any categories I choose for that particular post are for that post and that post only, regardless of whether I choose them again for other posts. So rather than "aggregate" all my categories and put them on every page (which is the default for Thematic at the moment), I want to be able to control which categories show for each particular post. I can't believe the code is that complicated to change, is it?

    Posted 4 years ago #
  18. @anthony99: Will these categories actually link to anywhere?

    And will you be making many posts to this site? It sounds as though it will only consist of a few pages where e.g. all the mexican food recipes will be on one page only.

    This is how I'm perceiving your site to look like at the moment:

    http://g.imagehost.org/0806/random.gif
    http://g.imagehost.org/0944/random2.gif

    Posted 4 years ago #
  19. anthony99,

    as far as I understood it, it's something like - still looking for a proper term that doesn't interfere with a WordPress term - ...

    It's something like an exclusive post for a certain category. You define one post that is exclusive for this one category.

    In this case you would need to 'filter' the category loop against a custom field.

    Chris

    Posted 4 years ago #
  20. anthony99
    Member

    flick, the images you show are just what I am trying to accomplish! How do I accomplish that? The only thing the categories will link to is "Mysitedotcom/categories"

    What about this code? Will it do the job?

    <?php
    //for 'first post' in wp_query display categories on that post
    $postid = $wp_query->posts[0]->ID;
    $postcats = get_the_category($postid);
    $ids=array();
    if ($postcats){
    foreach ($postcats as $postcat) {
    $ids[]=$postcat->cat_ID;
    }
    $cats = implode(",", $ids);
    $wlc_param_list='orderby=name&show_count=1&title_li=Categories on first post&include=' . $cats;
    wp_list_categories($wlc_param_list);
    }
    ?>

    Posted 4 years ago #
  21. anthony99
    Member

    I feel we are getting closer!

    Posted 4 years ago #
  22. @anthony99: Does this mean that regardless of the name of the category (be it burrito or taco) it will always link to 'yoursite.com/categories'?

    Presumably 'yoursite.com/categories/' will list all of the categories.

    Posted 4 years ago #
  23. anthony99
    Member

    Hello Flick

    Yes, that is correct!

    What about this code? Will it do the job?
    --------------------------------

    <?php
    //for 'first post' in wp_query display categories on that post
    $postid = $wp_query->posts[0]->ID;
    $postcats = get_the_category($postid);
    $ids=array();
    if ($postcats){
    foreach ($postcats as $postcat) {
    $ids[]=$postcat->cat_ID;
    }
    $cats = implode(",", $ids);
    $wlc_param_list='orderby=name&show_count=1&title_li=Categories on first post&include=' . $cats;
    wp_list_categories($wlc_param_list);
    }
    ?>

    Posted 4 years ago #
  24. anthony99
    Member

    Here is my current sidebar.php file:

    <?php thematic_abovemainasides(); ?>

    <?php if (is_sidebar_active('primary-aside')) { ?>
    <div id="primary" class="aside main-aside">
    <ul class="xoxo">
    <?php dynamic_sidebar('primary-aside'); ?>

    </div><!-- #primary .aside -->
    <?php } ?>

    <?php thematic_betweenmainasides(); ?>

    <?php if (is_sidebar_active('secondary-aside')) { ?>
    <div id="secondary" class="aside main-aside">
    <ul class="xoxo">
    <?php dynamic_sidebar('secondary-aside') ?>

    </div><!-- #secondary .aside -->
    <?php } ?>

    <?php thematic_belowmainasides(); ?>

    Do I add the code below to the end of this string?

    <?php
    //for 'first post' in wp_query display categories on that post
    $postid = $wp_query->posts[0]->ID;
    $postcats = get_the_category($postid);
    $ids=array();
    if ($postcats){
    foreach ($postcats as $postcat) {
    $ids[]=$postcat->cat_ID;
    }
    $cats = implode(",", $ids);
    $wlc_param_list='orderby=name&show_count=1&title_li=Categories on first post&include=' . $cats;
    wp_list_categories($wlc_param_list);
    }
    ?>

    Posted 4 years ago #
  25. anthony99
    Member

    Would it be better to download and install Otto's PHP Code Widget, then put that code in one of those widgets?

    http://wordpress.org/extend/plugins/php-code-widget/

    Posted 4 years ago #
  26. anthony99
    Member

    Problem solved!

    I installed the plugin php-code-widget

    http://wordpress.org/extend/plugins/php-code-widget/

    and then put this code into the widget:

    <?php
    //for 'first post' in wp_query display categories on that post
    $postid = $wp_query->posts[0]->ID;
    $postcats = get_the_category($postid);
    $ids=array();
    if ($postcats){
    foreach ($postcats as $postcat) {
    $ids[]=$postcat->cat_ID;
    }
    $cats = implode(",", $ids);
    $wlc_param_list='orderby=name&show_count=1&title_li=&include=' . $cats;
    wp_list_categories($wlc_param_list);
    }
    ?>

    Posted 4 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.