How to assign multiple categories to posts
-
Hi, I’m creating a simple website and we desire to categorize posts by year and by topic, and have users be able to combine them into a search somehow. Perhaps I mean “tags” when I say “categories,” but I’m not sure which to use here. For example, I’d like it so that clicking on “2012 journal articles” would show all posts which are categorized as “journal articles” and which are categorized “2012.” It seems to me I can use the Categories widget for this purpose and indeed I can, if I structure a fixed heirarchy of categories. However, this is very limited for two reasons. First, I want to be able to show just the categories I want but the Categories widget shows all categories. Also, I want to be able to create flexible combinations of categories without using an explicit heirarchy. That is, I want a user to be able to find all “journal article” posts that also are by a certain author. Etc. I originally imagined I’d use some sort of hard-coded queries on tag values, but I don’t know how to generate such query results. I’m thinking this must be a solved problem — any hints on how to proceed? I’m a newbie to wordpress but I do know C/C++, python, etc. Help! Thank you
-
If you have programming experience, this documentation should be pretty intuitive: https://codex.wordpress.org/Class_Reference/WP_Query
Write your own category.php and use the query vars to generate your own query and then display the posts as you see fit.
Thank you. I think that’s an advanced view, unfortunately, since I’m a newbie to wordpress. I don’t know what a wp-includes/query.php file is, for example. Since we are hosted at a 3rd party site, I’m not sure I can even edit this file. I’m hoping to achieve my aims through the use of widgets, plugins, and the like if possible. Is there hope for me? Is there a cool widget out there that will allow me to select arbitrary tag combinations?
I think I’ve found what I need: it’s called the “Posts by Tag” widget. No code required, combined with the “Widgetize Pages” plugin it allows me lots of flexbility the way I want.
The topic ‘How to assign multiple categories to posts’ is closed to new replies.