Wordpress

I"m trying lớn determine how to retrieve sầu custom values from wp_options when the values are stored in a single options array.

Bạn đang xem: Wordpress

For example, I"ve sầu 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:"Blachồng 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 sầu page for this category?


*

$term_id = get_query_var("cat"); // the current category ID$my_fields = get_option("my_category_fields_option");emang đến $my_fields<$term_id><"my_title">; // the title corresponding to lớn the current category(assuming you"re talking about Any examples of adding custom fields khổng lồ the category editor?)


*

*

If you pass an array to the update_option it will automatically serialize it. you can later retrieve them baông chồng inlớn an array lượt thích this.

$tempoptions = get_option("plugin-options");if (!empty($tempoptions)) foreach ($tempoptions as $key => $option) $options<$key> = $option;then bởi something lượt thích var_dump ($options) this will show you the entire array.

Xem thêm: Học Nghệ Thuật Bán Hàng Đỉnh Cao Online, Bán Hàng Chuyên Nghiệp

I think they use the maybe_serialize/maybe_unserialize/is_serialized functions from the codex, but I never really looked inlớn it. Just found them now. http://codex.wpuonline.com.org/Function_Reference/maybe_serialize


*

*

Thanks for contributing an answer to lớn wpuonline.com Development Staông chồng Exchange!

Please be sure lớn answer the question. Provide details và nói qua your research!

But avoid

Asking for help, clarification, or responding khổng lồ other answers.Making statements based on opinion; back them up with references or personal experience.

Xem thêm: Cách Xem Ai Vào Facebook Của Mình Bằng Điện Thoại, Cách Xem Ai Hay Vào Facebook Của Mình

To learn more, see our tips on writing great answers.


Post Your Answer Disthẻ

By clicking “Post Your Answer”, you agree to lớn our terms of service, privacy policy and cookie policy


Not the answer you're looking for? Browse other questions tagged plugin-development or ask your own question.


site kiến thiết / hình ảnh © 2021 Staông chồng Exchange Inc; user contributions licensed under cc by-sa. rev2021.4.5.38984


wpuonline.com is a trademark of the wpuonline.com Foundation, registered in the US and other countries. This site is not affiliated with the wpuonline.com Foundation in any way.

Your privacy

By clicking “Accept all cookies”, you agree Stachồng Exchange can store cookies on your device & discđại bại information in accordance with our Cookie Policy.


Chuyên mục: Theme wordpress