If you want to make an backend option within the Settings area, you must use the Settings API . To do within Theme settings you have to use the Theme Customization API . Each of them has functions to be called in the frontend and pull the values.
Another easy way is to create a Custom Post Type where you can register more than one footer option and pull on the frontend with the get_posts()
function.
In this example plugin, I'm creating a post type that only supports titles, see supports => array(SUAS-OPÇÕES)
:
<?php
/*
* Plugin Name: Rodapés personalizados
* Plugin URI: http://pt.stackoverflow.com/a/98553/201
* Version: 1.0
* Author: brasofilo
*/
add_action( 'init', 'footers_custom_init' );
# Ajustar $labels e $args conforme suas necessidades
function footers_custom_init() {
$labels = array(
'name' => 'Footers',
'singular_name' => 'Footer',
'add_new' => 'Add New',
'add_new_item' => 'Add New Footer',
'edit_item' => 'Edit Footer',
'new_item' => 'New Footer',
'all_items' => 'All Footers',
'view_item' => 'View Footer',
'search_items' => 'Search Footers',
'not_found' => 'No teasers found',
'not_found_in_trash' => 'No teasers found in Trash',
'parent_item_colon' => 'Parent Page',
'menu_name' => 'Footers'
);
$args = array(
'labels' => $labels,
'description' => '',
'public' => false,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array(),
'capability_type' => 'page',
'has_archive' => false,
'hierarchical' => true,
'menu_position' => 60,
'supports' => array( 'title')
);
register_post_type( 'footers', $args );
}
if ( ! function_exists( 'imprime_rodape' ) ) {
# Ajustar $args conforme suas necessidades
function imprime_rodape() {
$args = array( 'numberposts' => 1, 'orderby' => 'rand', 'post_type' => 'footers' );
$rand_footer = get_posts( $args );
echo $rand_footer[0]->post_title;
}
}
Next, in the footer.php
of your theme file, use the following plugin function to print a random footer:
<?php if ( function_exists( 'imprime_rodape' ) ) imprime_rodape(); ?>