WordPress.org

Ready to get started?Download WordPress

Forums

shortcode should allow other hooks, like 'publish_post' (1 post)

  1. heeb
    Member
    Posted 5 years ago #

    I am writing a plugin where I need to keep track of which posts contain certain content in shortcode tags. For example, consider a shortcode tag: [thing id="x"]. On a separate page, I would like to list all 'things', along with links next to each 'thing' of all posts where they appear. So if in post 1 I have [thing id='x'] and in post 4 I have [thing id='y'], then in my list, it would show thing x with a link to post 1 and thing y with a link to post 4.

    Currently, unless I'm mistaken, the shortcode API only works with viewing posts, but I would like to use the functionality using another hook such as 'publish_post', in which I would check the post for 'things' and modify the database accordingly.

    I know I could do this myself, maybe using shortcode_parse_atts()? I think this would be a nice default feature, though - allowing shortcode tags to be used for other purposes than when showing the content.

Topic Closed

This topic has been closed to new replies.

About this Topic