I’m trying to determine how to retrieve custom values from wp_options when the values are stored in a single options array.

For example, I’ve got the following data in wp_options for option_value where option_name = “my_category_fields_option”. The i:n value represents the category id of the category that holds the custom “my_title” data]

a:2:{i:10;a:1:{s:8:”my_title”;s:48:”Iced Tea: A Great Choice for Cooling Refreshment”;}i:20;a:1:{s:8:”my_title”;s:30:”Black Tea is Good for the Soul”;}}

How would I retrieve the value for “my_title” (which should be “Hello World”) when I’m viewing the category archive page for this category?

2 Answers
2

$term_id = get_query_var('cat'); // the current category ID

$my_fields = get_option('my_category_fields_option');
echo $my_fields[$term_id]['my_title']; // the title corresponding to the current category

(assuming you’re talking about Any examples of adding custom fields to the category editor?)

Leave a Reply

Your email address will not be published. Required fields are marked *