Support Forums

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro Filtering on custom taxonomy for attachment post-type

Viewing 8 posts - 1 through 8 (of 8 total)
  • Noeste IJver
    #235630

    Hi,

    I added a new taxonomy to the default ‘attachment’ post-type. I’d like to be able to filter images based on their color on an archive page. I added the taxonomy as a filter for Search & Filter and the actual filtering works like it should.

    However, the options ‘Hide empty terms?’ and ‘Display count?’ don’t work at all. Although there are images which have been ‘tagged’, all counters show (0) as count. When hiding all empty terms, all terms are gone, even the ones which actually have actually been used for images.

    See the following screen cap for more explanation:
    https://drive.google.com/file/d/1KClW3lY5BZOoZ_bCkRrH7WL-_ClXGcwJ/view?usp=sharing

    Trevor Moderator
    #235658
    This reply has been marked as private.
    Noeste IJver
    #235664
    This reply has been marked as private.
    Trevor Moderator
    #235685
    This reply has been marked as private.
    Noeste IJver
    #235688

    I figured out that the main problem is that WordPress doesn’t seem to update term-relationships for terms in the post type ‘attachment’. I think that’s the main problem and that’s not really related to Search and Filter.

    I wrote an SQL statement to update the count, and added it to the hooks ‘add_attachment’ and ‘edit_attachment’:
    “UPDATE wp_term_taxonomy SET count = (
    SELECT COUNT(*) FROM wp_term_relationships rel
    LEFT JOIN wp_posts po ON (po.ID = rel.object_id)
    WHERE
    rel.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
    )”

    This works, the count on the taxonomy page seems correct now. However, I added some extra filters in the ‘Post Meta’ tab of Search & Filter. The filter counters in Search & Filter don’t seem to take those into account. Do you notice this as well?

    Trevor Moderator
    #235723
    This reply has been marked as private.
    Noeste IJver
    #235727
    This reply has been marked as private.
    Ross Moderator
    #236305
    This reply has been marked as private.
Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.