Forums

Specific Post Filter (6 posts)

  1. InfiniteKnight
    Member
    Posted 3 years ago #

    This is the second of two issues I have with writing my plugin...

    I need to set a hook / action up to trigger only on posts to a specific category.

    Since these posts would have a very specific maximum length, would it be easier to:

    Setup the plugin's admin system to accept these posts directly, assigning them to the right category, and acting on them directly as part of it's code to put them into the DB...

    Or

    Set a hook or action up to trigger when a post is submitted, then have the function that is triggered test to see if the post is in the right category before acting on it, or ignoring it if it isn't?

    In the end, I want the posts to end up being able to be displayed like any other WP post, as well as part of the RSS feeds, etc, but I also want special code triggered that will work in concert with an external system to relay those posts to another setup.

    (And for those who ask, no, RSS isn't a viable option for the relay, even if you just pulled that specific category, there is way too much work to do for RSS to be usable in this matter, the work has to be handled by PHP for it to get done, as each post will trigger a large amount of interaction between WP and the external system in order for both to perform their respective functions.)

  2. InfiniteKnight
    Member
    Posted 3 years ago #

    Bump... Still trying to get an answer to this question...

  3. s_ha_dum (was apljdi)
    Member
    Posted 3 years ago #

    I'd take the second option. Much easier. You'd only have to worry about the relay, not the relay and post database inserts.

  4. InfiniteKnight
    Member
    Posted 3 years ago #

    The relay is the easy part... Down side is going with the second, means I have to risk only being able to send part of the post along the relay... I have a maximum length for posts via the relay of about 768 single byte characters, as a hard limit of the external API I am developing around, to allow for all possible external factors. So that means I would have to only send parts of long posts, versus being able to hard code a limit in the admin side form. From what I have seen, if you use the built in WP functions, adding a post isn't a big deal, and I can build my relay right into the same code very easy enough. (I already have a relay function tucked away inside a library I include using require_once in the various functions where I need them.) Thanks for the vote though... Would like to get a couple of other answers, to see what kind of over all consensus there is.

  5. s_ha_dum (was apljdi)
    Member
    Posted 3 years ago #

    Inserting a post isn't that big of a deal but it sounds like you'd be basically duplicating an admin page with one minor change, if you went with option 1.

    If you are confident that your users will have javascript enabled you ought to be able to cook up a script that will limit post content if and only if your special category is selected.

  6. InfiniteKnight
    Member
    Posted 3 years ago #

    Umm... I rarely have JS enabled, even on my own sites, (using Firefox with No Script), so I don't want to rely on the fact of users having JS turned on. I want to use strictly straight code, so no matter what it will operate correctly... The other issue would be is there a way to trigger a function to run if the category is selected? Going with the straight admin page, I could probably grab the excerpt, (which may be a bit confusing for someone to understand at first glance).

Topic Closed

This topic has been closed to new replies.

About this Topic