Creating custom theme options page

I am creating a theme for a client and it has a custom front page that has a slider and displays the services they offer. I am looking to add an options page where the client can easily update the slider images, service titles, descriptions and images. I have seen this functionality on other themes and am having trouble trying to implement it. I have followed a few different tutorials and I understand how to add the page to the menu, but am unsure how to get the form to update the information on the front page.

Most recently, I followed this tutorial exactly but could not get it to work. When I hit submit, it says “error: options page not found”. I saw this in a similar question here, but while the answer solved the error message, it still wasn’t updating the information on the front page.

Are there any ideas on how to do this? Or any tutorials that would be helpful? I’ve been looking but most of the tutorials are outdated or deal with the Settings API and not custom fields.

The code I’m using is from this tutorial from Webdesigner Depot. The main problem I have is that the inputted text does not get saved.

In functions.php:

add_action(‘admin_init’, ‘theme_options_init’);
add_action(‘admin_menu’, ‘theme_options_add_page’);

function theme_options_init(){
register_setting( ‘sample_options’, ‘sample_theme_options’);

function theme_options_add_page(){
add_theme_page( __( ‘Theme Options’, ‘sampletheme’ ),
__(‘Theme Options’, ‘sampletheme’),
‘edit_theme_options’, ‘theme_options’,

function theme_options_do_page() {
global $select_options;
if (!isset($_REQUEST[‘settings-updated’]))
$_REQUEST[‘settings-updated’] = false;

edit formatting.php in a theme so it wont get overwritten

There are some parts of wpautop I want to remove, but keep the rest. I found in wp-includes/formatting.php within the function wpautop:

$pee = preg_replace(‘|s*|’, ”, $pee); // under certain strange conditions it could create a P of entirely whitespace


$pee = preg_replace(‘|(?)s*n|’, “n”, $pee); // optionally make line breaks

Lines 251 & 261 in my version.

I want to delete these parts of the function, and deleting or // the lines works fine.

But how can I remove these lines in a theme file so it wont be overwritten in an update? Can I do something in functions?

Creating a custom abstract/excerpt function: retrieving text between a specific tag or id

Unfortunately, the functions for retrieving the abstract and the excerpt don’t fit my needs.

I want to define a part in my text that should function as abstract without falling back to JavaScript/jQuery as I do not want my readers to necessarily have it enabled for reading the content.

I want to define a custom tag or shortcode like [my_abstract] and retrieve the text between it. It also could be a div-tag with a specific id.

Unfortunately, I’m not well versed in PHP, could this be done?

Cant use php fopen() function in functions.php

I am trying to simple run fopen() in the functions.php, and have also tried it in a test.php wordpress template file.

But it does not work. If I move the test.php file and csv file to a location outside the theme folder then it works first time.

function csv_to_array($filename=”, $delimiter=’,’)
if(!file_exists($filename) || !is_readable($filename))
return FALSE;

$header = NULL;
$data = array();
if (($handle = fopen($filename, ‘r’)) !== FALSE)
while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
$header = $row;
$data[] = array_combine($header, $row);
return $data;

echo ”;
echo ”;

This is my folder structure in the theme file…

Any ideas why it does not work?