WordPress.org

Ready to get started?Download WordPress

Forums

TIEexpire Automated Post Expiry
[resolved] Expiration based on category (9 posts)

  1. danicasati
    Member
    Posted 5 months ago #

    Hi.
    Can this plugin auto-expire posts only in certain category?

    http://wordpress.org/plugins/tieexpire-automated-post-expiry/

  2. TIEro
    Member
    Plugin Author

    Posted 5 months ago #

    No, it can't. That's the first thing on my list for future development: inclusion and exclusion of categories.

    I do have a "jury-rigged" version that I use on a couple of my own sites, where I've adjusted the code to exclude a single category, but nothing properly developed yet.

    If you want to exclude a single category and are comfortable messing with code, you can add this to whichever query or queries you desire:

    AND $wpdb->posts.ID NOT IN (SELECT DISTINCT object_id FROM $wpdb->term_relationships
      WHERE $wpdb->term_relationships.term_taxonomy_id = [category number])

    Including only a single category in the expiry check is done by taking out the "NOT" on the first line.

    The main reason I haven't included categories yet is that the options are so complicated. Including/excluding one or more categories globally is a lot simpler than providing the option for each expiry type, especially when it comes to keeping the options screen layout readable!

  3. danicasati
    Member
    Posted 5 months ago #

    Thank you for the code, I'll try it.
    Maybe, in future version I could test this feature...

  4. TIEro
    Member
    Plugin Author

    Posted 5 months ago #

    No problem. Actually, while I'm here...

    Include a single category:

    AND $wpdb->posts.ID IN (SELECT DISTINCT object_id FROM $wpdb->term_relationships
      WHERE $wpdb->term_relationships.term_taxonomy_id = [category number])

    Exclude multiple categories:

    AND $wpdb->posts.ID NOT IN (SELECT DISTINCT object_id FROM $wpdb->term_relationships
      WHERE $wpdb->term_relationships.term_taxonomy_id IN ([category number], [category number], [category number]))

    Include multiple categories:

    AND $wpdb->posts.ID IN (SELECT DISTINCT object_id FROM $wpdb->term_relationships
      WHERE $wpdb->term_relationships.term_taxonomy_id IN ([category number], [category number], [category number]))

    Not incredibly efficient, any of them, but they'll work. :)

  5. TIEro
    Member
    Plugin Author

    Posted 5 months ago #

    v1.0.3 being developed right now, with category inclusions and exclusions. Bear with me.

    (The code above does work: I originally posted here that it didn't, but I'd screwed up the code in the dev version, not the stuff on this page. It's been a long day. :) )

  6. danicasati
    Member
    Posted 5 months ago #

    No problem, maybe I help you beta-testing next version...

  7. TIEro
    Member
    Plugin Author

    Posted 5 months ago #

    v1.0.3 is now available. I've tested it on my own data and sites, but obviously it's worth keeping an eye on for a day or two.

    Hopefully it will answer all your needs!

  8. danicasati
    Member
    Posted 5 months ago #

    Thank you, I'll try it during next hours.

  9. TIEro
    Member
    Plugin Author

    Posted 5 months ago #

    Marked resolved, due to v1.0.3 functionality. :)

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.