I am trying to store simple data, a few links inside wp_options. Basically using the following way: update_option( 'simple_links', '<a href="">link 1</a>' );
my question is if it is allowed, I dont want to create new table for it, just a few links permanently stored inside the footer. Is that the valid way and will it actually save data inside options? Or there is any other better way for such a simple need?
Thank you.
To recap the comment chain above:
I think that’s a perfectly valid way of storing some options in the database, however, it’s good practice to prepend your option name with some unique characters pertaining to your site or something, like
'my_simple_links'
to avoid possible collisions with other plugins and themes thatadd_option
s.Also, if you’re going to have multiple links they could be stored as an array inside one option by passing the array as the second argument (serialization will be performed automatically).
Accessing them from your theme would be as easy as:
Better yet store them in an associative array as
title => url
and do this:And don’t forget to read the Codex on:
get_option()
add_option()
update_option()