admin管理员组

文章数量:1315118

I'm trying to think of the best way of being able to edit a certain custom field on a global basis rather than having to go into each post and editing it.

For example an affiliate link custom field which the link will be different for each post/page. It would be better to be able to add all the links to all the pages/posts via a single screen rather than going into each post and adding a link into the field.

I've tried searching for similar solutions but maybe i'm not using the correct terminology to get the desired results. Any pointers would be highly appreciated .

I'm trying to think of the best way of being able to edit a certain custom field on a global basis rather than having to go into each post and editing it.

For example an affiliate link custom field which the link will be different for each post/page. It would be better to be able to add all the links to all the pages/posts via a single screen rather than going into each post and adding a link into the field.

I've tried searching for similar solutions but maybe i'm not using the correct terminology to get the desired results. Any pointers would be highly appreciated .

Share Improve this question asked Jan 3, 2018 at 18:32 Randomer11Randomer11 41611 silver badges31 bronze badges 1
  • 4 How about an options page in your plugin? wordpress.stackexchange/questions/250753/… – jdm2112 Commented Jan 3, 2018 at 18:34
Add a comment  | 

1 Answer 1

Reset to default 1

I would use an option page which would show up in the settings. I used Example #2 from here for a few of my projects.

Then you would use it in your theme like this:

$o = get_option('my_option_name'); // how you named the options from Example #2
$field = $o['field_name']; // how you named the field
echo $field;

本文标签: Best way to contruct a global custom field