One more common request is to make the “ Read More ” text in the archive pages editable. Let ’ s precisely do that in this moral .
Go ahead and put the take after code at the end of the nd_dosth_customize_register action :

// Setting for Read More text.
$wp_customize->add_setting( 'nd_dosth_readmore_text',
        'type'              => 'option',
        'default'           => __( 'Read More ', 'nd_dosth' ),
        'sanitize_callback' => 'sanitize_text_field',
        'transport'         => 'refresh',
// Control for Read More text
$wp_customize->add_control( 'nd_dosth_readmore_text', 
        'type'        => 'text',
        'priority'    => 10,
        'section'     => 'nd_dosth_text_options',
        'label'       => 'Read More text',
        'description' => 'Text put here will be as the text for Read More link in the archives',

You already know what ’ s happening in the above code. It barely adds a fresh Control and Setting for “ Read More ” text inside :
Customize Panel – > Theme Options – > Text Options

Nothing newfangled, properly ?
But if you notice the add_setting() function in the above code, I added an extra controversy called “ type ” to its configuration array and I have provided “ option ” as its prize .


The “ type ” argumentation accepts two values .

  1. theme_mod (default)
  2. option

The default value for the “ type ” argument is “ theme_mod ”. This is why we did not provide this argumentation for the “ Copyright Text ” Setting and we used the get_theme_mod() officiate to retrieve the Setting prize .
But I want the “ Read More ” Setting to be the type of “ option ”, so I have specified the “ type ” without omitting it .
The importance of the “ type ” argumentation is that it tells WordPress how to store a particular Setting ’ s value inside the WP_OPTIONS table. That ’ s all .
This will make more sense if you take a search at how “ Copyright Text ” Setting is shop inside the WP_OPTIONS table .


See ? not fair “ Copyright Text ” Setting, All the Settings inside Customize Panel whose type is “ theme_mod ” are getting store inside a single row of the table called “ theme_mods_nd-dosth ” .
If you have some full amount of cognition about Database Performance, you know this is not good for operation .
This is where the Setting type of “ option ” comes in .
You know the Settings Screen inside the Admin Dashboard, correct ?


Along with some inner WordPress settings, The values of all the above Settings are stored the WP_OPTIONS as well, but each Setting gets its own rowing !


so, if we set the “ type ” of a particular Customization Setting to “ choice ”, this Setting ’ sulfur rate will get its own inside the WP_OPTIONS table and there will be a performance boost when we access this Setting ’ s value for outputting in the frontend .
Common, let ’ s quiz this out ! Go back to the Text Options :

Admin Dashboard – > Appearance – > Customize – > Theme Options – > text Options
And change the text of “ Read More Text ” Setting to “ Continue Reading ” and hit the Publish button to save changes to the Database .


If we now check out the WP_OPTIONS table, we can indeed see that “ Read More Text ” Setting got its own rowing .


Trust me, This is a very well thing .
anyhow, immediately let ’ s retrieve and output “ Read More Text ” Setting inside our Blog posts Index and archive pages .
If you remember, we are outputting the “ Read More ” associate from the parts/blog-index.php template file. We are using this template separate to render the web log posts on the Blog mail index page, Homepage, and archive pages .
Seeing the advantage of writing modular template parts so far ?
Go ahead and open up the blog-index.php template file and replace the follow code :

With :


Because we have the Setting type to be “ option ”, we can no longer use the get_theme_mod() affair to retrieve the value of the Setting. alternatively, we have to use get_option() function .
The get_option() serve accepts the same two parameters that the get_theme_mod() affair accepts. Setting ID and a Default Value .
That ’ s all .
If you now go to the Blog posts Index, Homepage or any of the archive pages, on individual articles, you should see the textbook “ Continue Reading ” alternatively of “ Read More ” .


Slick, Isn ’ t it ?
here is one more unavowed, the get_theme_mod() affair internally uses the get_option() function. So you can even retrieve and output a Setting with “ theme_mod ” type using the get_option() affair as well. It saves one internal function call for WordPress.

Common, go ahead and replace the get_theme_mod() officiate inside the footer.php file with the get_option() routine .

    '%s. %s © %s', 
    get_option('nd_dosth_copyright_text', __( 'All Rights Reserved', 'nd_dosth' ) ),
    date_i18n( 'Y' )

Everything inactive works the like. From here onwards, for the remainder of the module, We will use get_option() function alternatively of get_theme_mod() function .
In the adjacent lesson, we will learn how to create a “ Checkbox ” Control and how to sanitize it .

Leave a Reply

Your email address will not be published.