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 that add_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:
<?php
$my_simple_links = get_option( 'my_simple_links' );
foreach ($my_simple_links as $link )
echo $link;
?>
Better yet store them in an associative array as title => url
and do this:
<?php
$my_simple_links = get_option( 'my_simple_links' );
foreach ( $my_simple_links as $title => $url )
echo '<a href="'.$url.'">'.$title.'</a>';
?>
And don't forget to read the Codex on:
'my_simple_links'
to avoid possible collisions. Also, if you're going to have multiple links you can store an array inside one option by passing the array as the second argument (serialization will be performed automatically). Hope this helps.foreach ($links as $link) echo $link;
$array_var_name['value']
and objects:$object_var_name->value
. Php.net is a good ressource for further research on that topic. Also: Don't forget to useesc_attr()
on your values before dumping it into the DB.