$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>categories - Group posts by custom post type|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

categories - Group posts by custom post type

matteradmin9PV0评论

I created a custom post type called Game, and created 3 posts under it, Game A, Game B and Game B.

I also want to create more posts, like guides and tutorials, for Game A, is thre a way to group these posts under Game A? I can create a tag called Game A, and group the posts under it. but then I will have duplicate tag and a post for custom post type.

Right now, the only ways (that I know) to group posts are by tag and category. I am clueless when it comes to grouping posts for a post created with a custom post type.

Thank you.

I created a custom post type called Game, and created 3 posts under it, Game A, Game B and Game B.

I also want to create more posts, like guides and tutorials, for Game A, is thre a way to group these posts under Game A? I can create a tag called Game A, and group the posts under it. but then I will have duplicate tag and a post for custom post type.

Right now, the only ways (that I know) to group posts are by tag and category. I am clueless when it comes to grouping posts for a post created with a custom post type.

Thank you.

Share Improve this question asked Jan 6, 2019 at 22:59 Noob CoderNoob Coder 1691 silver badge8 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Solution 1.

As you've already mentioned, you can use terms, but - it will cause some redundancy, because for every post you'll have to create a term. And you'll have to maintain this post-term connection later on.

Solution 2.

On the other hand, you can use Custom Fields. So for every Guide and Tutorial you can add Custom Field like "related_game_id" and store the ID of related game in that field.

You can use Advanced Custom Fields and its Relation field to make some nicer interface for editing these relations.

Solution 3.

But there is one more way of achieving this. You can remove CPT Game and add Custom Taxonomy Game.

Then you can add this taxonomy to Guides, Tutorials, and all other post types and use description of a term to edit Game info.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far