WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#4015 closed defect (bug) (fixed)

Post and link category confusion

Reported by: donncha Owned by: ryan
Milestone: 2.3 Priority: normal
Severity: normal Version: 2.2
Component: Administration Keywords: developer-feedback
Focuses: Cc:

Description

If a category has links added to it but is a parent of categories with posts, or is a parent of categories you want to see in the Write page then none of the child categories will show.
See the SQL in wp-admin/admin-functions.php:return_categories_list();

Fix? Display all categories on the Write page regardless of link_count value.

Attachments (2)

4015.diff (679 bytes) - added by rob1n 8 years ago.
cat_scope.diff (5.0 KB) - added by Tjworld 8 years ago.
cat_scope patch for 2.1.3

Download all attachments as: .zip

Change History (22)

comment:1 @foolswisdom8 years ago

  • Version set to 2.2

comment:2 follow-up: @Otto428 years ago

+1

In fact, we should consider displaying all categories on both the write post/page as well as on the bookmarks add screen. There is really no reason to prevent a category from containing both posts and links, and it would give potential to some interesting mashups and plugins and such.

Example: I think it would be neat if my added Bookmarks could be shoved into my posts loop, so that links I add could show up as one-liners between posts. Then I could categorize them and such. Kind of like asides, but with just links, no real post info required.

As it stands now, blocking categories with links from appearing on the post screen and blocking categories with posts from appearing on the links screen causes more confusion than it prevents.

There will, of course, be complaining as people with loads of categories suddenly see all them in places they were not expecting, but that will be limited.

comment:3 @ryan8 years ago

We used to do it that way but the complaining was quite loud. I personally would prefer to eliminate the count checks and just show everything.

@rob1n8 years ago

comment:4 @rob1n8 years ago

  • Owner changed from anonymous to rob1n
  • Status changed from new to assigned

Patch drops the count checks.

comment:5 @rob1n8 years ago

  • Keywords has-patch added

comment:6 @rob1n8 years ago

  • Owner changed from rob1n to ryan
  • Status changed from assigned to new

Reassigning to ryan to [maybe] commit.

comment:7 @ryan8 years ago

Let's hold off for now. This change will create flames.

comment:8 in reply to: ↑ 2 @foolswisdom8 years ago

  • Milestone changed from 2.2 to 2.3
  • Priority changed from high to normal

Replying to Otto42:

There is really no reason to prevent a category from containing both posts and links

The reason it can be a bad idea is an overwhelming list. This is a symptom of the current UI, and maybe also a symptom of not having tags -- we will see.

With a single catalog, with this UI, intuitively you would want:
Created on post page -> always display in post catalog, not in blogroll if no links
Created on blogroll page -> always display in blogroll, not in post page if no posts
Created in category management -> always display in both

comment:9 @Tjworld8 years ago

I’ve just spent the best part of a morning trying to work out why 60 categories weren’t showing up when posting/editing, after assigning them to links.

I hacked the code and found the SQL clause in return_categories_list() causing the issue. It makes no sense to me, definitely counter-intuitive and even illogical.

As a solution, how about adding an integer field "cat_scope" to wp_categories?

"cat_scope" would have the values: 0 = Both, 1 = Posts, 2 = Links.

In the "Edit Category" form add a radio-button field "Scope: * Both * Posts * Links"

Then modify the SQL queries in return_categories_list() and return_link_categories_list() to use the new field as the discriminator instead of the AND/OR logic.

comment:10 @karmadude8 years ago

I had figured this solutions back in feb, and I have been using it on my blog, and it works well. It allows the same category to be used for posts and links, and very useful when you want to show post category specific links.

comment:11 @Otto428 years ago

karmadude: I made the same change to my core code just after 2.1 came out too, and have continued to make the change every upgrade. It's a heck of a lot nicer to have all the categories available for both posts and links, even if I don't use them. All the user confusion goes away when you can see the categories as one unit.

All I did was to change the return statements in return_categories_list() and return_link_categories_list() to both do this:

return $wpdb->get_col( "SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY link_count DESC" );

Completely eliminate the count checks and allow all categories to show everywhere. It's so much simpler and easier to use. Create a new category and it shows up right away. Categories don't disappear from links just because you make posts to them and vice versa. Things work the way that the user expects them to work.

I'll continue making this change to my own code. And if we're not going to fix the broken core categories code to allow this, then we should at least add hooks so that I can turn this sort of behavior into a plugin instead of a core hack.

@Tjworld8 years ago

cat_scope patch for 2.1.3

comment:12 follow-up: @Tjworld8 years ago

A follow-up to my suggestion of adding the "cat_scope" to wp_categories table, and allowing each category to be set to belong to one of 'Both', 'Post', 'Link'.

I've tested this and it works nicely. It had the added benefit that when a parent category is, say, 'Link' only, all that categories children are hidden from the Post Category list, so the heirachy is maintained.

I've attached a patch generated against WordPress 2.1.3

comment:13 @Tjworld8 years ago

cat_scope:

The WordPress database will need the field adding. From a terminal do:

$ mysql -u <username> -p <database>
Enter password: *

mysql> ALTER TABLE wp_categories ADD COLUMN cat_scope INT default 0;
mysql> quit

This assumes your tables are prefixed "wp_". Change the line above if using a different prefix.

comment:14 in reply to: ↑ 12 @foolswisdom8 years ago

  • Keywords developer-feedback added; has-patch removed

Replying to Tjworld:

A follow-up to my suggestion of adding the "cat_scope" to wp_categories table, and allowing each category to be set to belong to one of 'Both', 'Post', 'Link'.

Fixing this bug likely depends on #4189: Taxonomy Schema and API

comment:15 @Otto428 years ago

The category stuff is changing into the new combined taxonomy stuff, most likely, so I would not suggest that any work be done on this code since it's probably all going away.

Still, I would like those working on the taxonomy to consider eliminating the separation between link and post categories in the process of their changes. This separation adds way more confusion than it can ever produce.

comment:16 follow-up: @ryan8 years ago

  • Resolution set to fixed
  • Status changed from new to closed

Full separation seemed to be the popular choice, so there is now separate category and link category management. Resolving as fixed.

comment:17 in reply to: ↑ 16 @karmadude8 years ago

Replying to ryan:

Full separation seemed to be the popular choice, so there is now separate category and link category management. Resolving as fixed.

Can the same category be used for both posts and links? For example if I have a category Videos, and I want to post a youtube video or a link to youtube.com

In this scenario do I have to have two videos categories; One for links and another for posts? If this is the case, then the issue of this ticket still exists.

comment:18 @karmadude8 years ago

I just checked 2.3 Beta 1, and looks like link and post categories have been separated out again. For those who modified the code and have been using the same category for links and posts, upgrading to 2.3 might duplicate all your categories and break all the functionality which expects the categories to be same.

This is going to be a lot harder than the previous version to have same categories for both links and posts because of the new taxonomy tables. But there is a little trick that might work: let's say we have a post category called video, if an extra entry is made to the term_taxonomy table for the video category, and set taxonomy to link_category, it might just work. I will have to try this out.

The upgrade script will have to be modified to include this extra step, otherwise, it's going to wreck havoc!

It's just lame when people conveniently drop obvious functionality for the sake of popularity. I mean come on, you added tags to posts, but no tags for links!! At least that would have provided the commonality some of us are looking for with categories.

comment:19 follow-up: @foolswisdom8 years ago

karmadude, thank you for participating in WordPress! You know your approach is on unstable ground when you write "for those who modified the code".

comment:20 in reply to: ↑ 19 @karmadude8 years ago

Replying to foolswisdom:

karmadude, thank you for participating in WordPress! You know your approach is on unstable ground when you write "for those who modified the code".

Well foolswidom, reality is some people do modify Wordpress for certain functionality! Some of the comments in the post(which is conveniently ignored), justifies that. If you want to do something about stable footing see #4883

Thanks, and an enhancement is much appreciated, and will help of some of us get on stable footing!

Note: See TracTickets for help on using tickets.