最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Access saved OptionsSettings

programmeradmin0浏览0评论

For some reason, I am battling to make sense of everything. This is my code on paste bin:

I want to be able to retrieve the options that are saved in the fields. This does not return anything:

<a href="<?php echo get_option('contact_details_vimeo_render'); ?>" target="_blank">
    <i class="fa fa-vimeo" aria-hidden="true"></i>
</a>

I basically want to be able to retrieve the stored data as desired.

For some reason, I am battling to make sense of everything. This is my code on paste bin: http://pastebin/dJxGS6x6

I want to be able to retrieve the options that are saved in the fields. This does not return anything:

<a href="<?php echo get_option('contact_details_vimeo_render'); ?>" target="_blank">
    <i class="fa fa-vimeo" aria-hidden="true"></i>
</a>

I basically want to be able to retrieve the stored data as desired.

Share Improve this question edited Oct 20, 2019 at 8:10 fuxia 107k39 gold badges255 silver badges459 bronze badges asked Jan 12, 2017 at 14:49 user23355user23355 3
  • And you are sure that the data is stored in the options table? – Robbert Commented Jan 12, 2017 at 14:54
  • @Robbert – yes I am sure. This is what's stored a:6:{s:25:"contact_details_telephone";s:14:"+27 21 999 9999";s:19:"contact_details_fax";s:14:"+27 21 999 9999";s:21:"contact_details_email";s:16:"[email protected]";s:28:"contact_details_facebook_url";s:0:"";s:23:"contact_details_twitter";s:0:"";s:32:"contact_details_textarea_field_5";s:80:"Adderess Line1, Address Line2, 8001, Cape Town, South Africa ";} – user23355 Commented Jan 12, 2017 at 15:03
  • This is a serialized option. You need to unserialize it to get your option. – Robbert Commented Jan 12, 2017 at 15:12
Add a comment  | 

2 Answers 2

Reset to default 0

Because your options are stored in one overarching serialized option, you have to make a function like below to retrieve the right option.

<?php 
function get_contact_details_setting( $option ) {
   $contact_details_settings = unserialize( get_option( 'contact_details_settings' ) );
   return $contact_details_settings[$option];
}
?>

Clearly I wasn't thinking :-(

Since all my options/settings are wrapped in a function that's how I need to retrieve them.... Do you get it? Using the function (I mean... hello!).

Rough code: $x = contact_details_telephone_render(); echo $x;

That will display the telephone number.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论