siga
6/5/2015 - 12:43 PM

Adds "Read more" to WP customizer. Code goes in CUSTOM FUNCTIONS in Dynamik - Dont forget to check the box "Affect Admin". Credits: Junior A

Adds "Read more" to WP customizer. Code goes in CUSTOM FUNCTIONS in Dynamik - Dont forget to check the box "Affect Admin". Credits: Junior Atoms. http://cobaltapps.com/forum/forum/main-category/web-design-talk/42707-how-do-i-get-the-read-more-button-to-show-up?p=67578#post67578

//* Add read more to customize -code by junior atoms
add_action( 'customize_register', 'jr_register_read_more_customize' );
function jr_register_read_more_customize( $wp_customize ) {

    $wp_customize->add_section(
        'jr_read_more_section',
        array(
            'title'     => 'Read More',
            'priority'  => 200
        )
    );

    $wp_customize->add_setting(
        'jr_read_more_setting',
        array(
            'sanitize_callback'  => 'jr_sanitize_read_more_text',
            'transport'          => 'refresh'
        )
    );

    $wp_customize->add_control(
        'jr_read_more_setting',
        array(
            'section'  => 'jr_read_more_section',
            'label'    => 'Read More Text',
            'type'     => 'text'
        )
    );

}

//* Sanitize the customize read more text
function jr_sanitize_read_more_text( $input ) {
    
    return wp_kses_post( force_balance_tags( $input ) );

}

//* Filter the read more text
add_filter( 'excerpt_more', 'jr_customize_read_more' );
add_filter( 'get_the_content_more_link', 'jr_customize_read_more' );
add_filter( 'the_content_more_link', 'jr_customize_read_more' );

//* Get the custom read more text
function jr_customize_read_more() {

    $custom_read_more = get_theme_mod( 'jr_read_more_setting', 'Read More' );
    
    return '&nbsp;<a class="more-link" title="' . $custom_read_more . '" href="' . get_permalink() . '">' . $custom_read_more . '</a>';

}  
//* End of read more function