If I write a post that I assign to multiple Categories I want to set one of them as the “Main Category” so that I can automatically call posts from that category to appear as “related posts” links etc.
For example using
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php $category = get_the_category($postID); $catid = $category->cat_ID; ?> <?php query_posts('cat='.$catid.'&showposts=3');
would always automatically give me the posts from the “alphabetically first” category (if multiple are chosen), which usually is not the category I want, and rewriting the above code for every single post is obviously no solution.
Article: “How to write good WordPress articles”
Article Categories: “WordPress” and “Article Writing”
Problem: I only want posts to get displayed from category “WordPress” but because of the alphabetical order posts from “Article Writing” category would get displayed first.
- The topic ‘How to define “Main” category in posts with multiple categories?’ is closed to new replies.