I am having trouble calling a field and displaying its content at the frontend from a custom theme option page. This is the code I am using to display my custom theme option at the backend
add_action( 'admin_init', 'theme_options_init' );
add_action( 'admin_menu', 'theme_options_add_page' );
/** Init plugin options to white list our options **/
function theme_options_init(){
register_setting( 'options', 'website_options', 'theme_options_validate' );
}
/** Load up the menu page **/
function theme_options_add_page() {
add_theme_page( __( 'Blurb Options', 'websiteBlurbs' ), __( 'Blurb Options', 'websiteBlurbs' ), 'edit_theme_options', 'theme_options', 'theme_options_do_page' );
}
/** Create the options page **/
function theme_options_do_page() {
if ( ! isset( $_REQUEST['settings-updated'] ) )
$_REQUEST['settings-updated'] = false;
?>
<div class="wrap">
<?php screen_icon(); echo "<h2>" . get_current_theme() . __( ' Page Settings', 'websiteBlurbs' ) . "</h2>"; ?>
<?php if ( false !== $_REQUEST['settings-updated'] ) : ?>
<div class="updated fade"><p><strong><?php _e( 'Options saved', 'websiteBlurbs' ); ?></strong></p></div>
<?php endif; ?>
<form method="post" action="options.php">
<?php settings_fields( 'options' ); ?>
<?php $options = get_option( 'website_options' ); ?>
<table class="form-table">
<td><h2>About Page</h2></td>
<?php /* ABOUT */ ?>
<tr valign="top"><th scope="row"><?php _e( 'Title Blurb', 'aboutBlurb' ); ?></th>
<td>
<input id="website_options[about]" class="regular-text" type="text" name="website_options[about]" value="<?php esc_attr_e( $options['about'] ); ?>" style="width:50%; padding:1em;" />
<label class="description" for="website_options[about]"></label>
</td>
</tr>
<td><h2>Our Team</h2></td>
<?php /* PROPERTY */ ?>
<tr valign="top"><th scope="row"><?php _e( 'Title Blurb', 'teamBlurb' ); ?></th>
<td>
<input id="website_options[team]" class="regular-text" type="text" name="website_options[team]" value="<?php esc_attr_e( $options['team'] ); ?>" style="width:50%; padding:1em;" />
<label class="description" for="website_options[team]"></label>
</td>
</tr>
<td><h2>Property Page</h2></td>
<?php /* PROPERTY */ ?>
<tr valign="top"><th scope="row"><?php _e( 'Title Blurb', 'propertyBlurb' ); ?></th>
<td>
<input id="website_options[property]" class="regular-text" type="text" name="website_options[property]" value="<?php esc_attr_e( $options['property'] ); ?>" style="width:50%; padding:1em;" />
<label class="description" for="website_options[property]"></label>
</td>
</tr>
</table>
<p class="submit">
<input type="submit" class="button-primary" value="<?php _e( 'Save Options', 'websiteBlurbs' ); ?>" />
</p>
</form>
</div>
<?php
}
/** Sanitize and validate input. Accepts an array, return a sanitized array. **/
function theme_options_validate( $input ) {
// Say our text option must be safe text with no HTML tags
$input['about'] = wp_filter_nohtml_kses( $input['about'] );
$input['property'] = wp_filter_nohtml_kses( $input['property'] );
$input['team'] = wp_filter_nohtml_kses( $input['team'] );
return $input;
}
I know how to call a field from a custom post type by using echo get_post_meta($post->ID, 'customfieldname', true); but when I try using this to call field aboutBlurb i am unable to generate the content from the field to display at the frontend. I am not receiving any errors or a reasons why I can not display it.
What am I missing to make this work correctly?