0

I've added a custom setting in Theme>Customize using Theme Customization API. Now, my client wants that setting (text) to show at the end of each & every blogpost. Please help.

My Current Code for Adding a New Setting:

function my_register_additional_customizer_settings( $wp_customize ) {
$wp_customize->add_setting(
    'my_company_name',
    array(
        'default' => '',
        'type' => 'option', // you can also use 'theme_mod'
        'capability' => 'edit_theme_options'
    ),
);

$wp_customize->add_section( 'my_company_name' , array(
'title'      => __( "Zaeem's Custom Section", 'mytheme' ),
'priority'   => 30,
));

$wp_customize->add_control( new WP_Customize_Control(
    $wp_customize,
    'my_company_name',
    array(
        'label'      => __( 'Add Text', 'textdomain' ),
        'description' => __( 'This text appears at the end of each blogpost', 'textdomain' ),
        'settings'   => 'my_company_name',
        'priority'   => 10,
        'section'    => 'my_company_name',
        'type'       => 'text',
    )
) );}add_action( 'customize_register', 'my_register_additional_customizer_settings' );

Code For Adding text under Each Post:

function add_my_content($content) {
$my_custom_text = '<p style="color:red;">Zaeem added a custom text at the end of every blog post.</p>';

if(is_single() && !is_home()){
    $content .= $my_custom_text;
}
return $content;}add_filter('the_content','add_my_content');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.