Skip to main content
We are Brand SEO Beijing serving international business, your marketing partner, Contact us by

Website production theme development example Add secondary settings page

Add secondary settings page

Referring to this sample code, you can use Ashuwp_framework to create a page with secondary settings: bottom settings.
demo footer 1-brand-SEO-public opinion-optimization-米国生活

import frame

Add the following code to the functinos.php file of the theme. There is no config.php configuration file in the downloaded framework. You need to create it yourself. Of course, the file name is optional.

//Load framework file require get_template_directory() . '/ashuwp_framework/ashuwp_framework_core.php'; //Configuration file require get_template_directory() . '/ashuwp_framework/config.php';

top page

Before adding a secondary setting page, you need to have a top-level setting page. To add a top-level setting page, please refer to: Add a simple setting page
This sample code assumes that a top-level settings page with 'filename' => 'generalpage' has been configured.

configuration code

/***footer option***/ $footer_info = array( 'full_name' => 'bottom settings', 'optionname'=>'footer', 'child'=>true, 'desc' => ' Ashuwp Framework ' , 'parent_slug'=>'ashuwp_page', 'filename' => 'footerpage' ); $footer_option = array(); $footer_option[] = array( 'name'=>'copyright', 'id'=>'copyright ', 'desc'=>'', 'std'=>'', 'type'=>'tinymce' ); $footer_option[] = array( 'name'=>'third-party code', 'id'= >'_code_tongji', 'desc'=>'Add third-party code before the </body> tag', 'std'=>'', 'type'=>'textarea' ); $footer_option_page = new ashuwp_options_feild($ footer_option, $footer_info);

Front-end code reference

Copyright output

copyright is a text editor in the background, so the content of this field cannot be output directly using echo.

footer, the name saved in the database is ashuwp_footer //All data of the entire setting page is saved in a record in the database //$footer_option gets an array/** $footer_option structure is as follows array( 'ashuwp_copyright' = > 'Copyright © 2017 tree workshop. All rights reserved.'; 'ashuwp_code' => ''; ) **/ $footer_option = get_option('ashuwp_footer'); //Because it is the content saved by the text editor, links are allowed, etc. Label if( !empty($footer_option['ashuwp_copyright']) ){ $ashuwp_copyright = apply_filters('the_content', $footer_option['ashuwp_copyright']); $ashuwp_copyright = str_replace(']]>', ']]>' , $ashuwp_copyright); echo $ashuwp_copyright; } ?>
output of code

This example can add some third-party code, such as statistical code, inused in front of the label.Note that the output of the code cannot be directly output by echo, because the predefined characters will be converted into character entities when the data is saved into the database, so use htmlspecialchars_decode to convert the character entities into characters before output.

demo footer-brand-SEO-public opinion-optimization-米国生活
Reprinted from: Ashu theme making tutorial

Back to Top