WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Get option name by value

[Resolved] Get option name by value

  • Topher

    @topher1kenobe

    I have a custom content type with a meta field holding a value of “Boys Basketball”.

    I also have a WordPress option that has a taxonomy id in the name, and “Boys Basketball” in the value.

    How can I get the option name (taxonomy_234 in this case) knowing ONLY the value that I have?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Topher

    @topher1kenobe

    Update: I see how I could get this info with a raw mysql query, I’m wondering if there’s a WordPress Way.

    esmi

    @esmi

    Forum Moderator

    Topher

    @topher1kenobe

    No, that’s the opposite of what I need. That gets the value by name. I need the name by value.

    Topher

    @topher1kenobe

    If I were to do it in sql it would be:

    SELECT
      option_name
    FROM
      options_table
    WHERE
      option_value LIKE '%program%'
    AND
      option_value LIKE '%Boys Basketball%'
    AND
      option_name LIKE '%taxonomy_%'

    and my row looks like this:

    option_id	option_name	option_value	autoload
    195776	taxonomy_294	a:1:{s:7:"program";s:15:"Boys Basketball";}	yes

    Topher

    @topher1kenobe

    I accomplished what I needed with a raw query. I wrote it as a fairly feature complete plugin which I’d be willing to release if anyone were ever interested.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] Get option name by value’ is closed to new replies.
Skip to toolbar