store simple data in get_option()

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_options.

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:

Leave a Comment