This thread is over two years old and may be outdated. Please create a new thread if you need help, or email us if you have an active Premium license.

Template file filter

Hi! I’am trying to replace basic sow-testimonials widget themplate by this gide – Template file filter, but nothing work, what i do wrong?

this code i put into functions.php in child theme:

function mytheme_testimonials_template_file( $filename, $instance, $widget ){
    if( !empty($instance['design']['theme']) && $instance['design']['theme'] == 'test' ) {
		 // This option works for plugins
        $filename = plugin_dir_path( __FILE__ ) . 'tpl/default.php';
        // And this one for themes
        $filename = get_stylesheet_directory() . '/tpl/1.php'; // this modify copy of original default.php in widget dirrectory
    }
    return $filename;
}
add_filter( 'siteorigin_widgets_template_file_sow-testimonials', 'mytheme_testimonials_template_file', 10, 3 );

This is our free support forum. Replies can take several days.

Need fast email support? Get SiteOrigin Premium

Replies

2
  1. Alex S Staff 8 years, 4 months ago

    Hi Constantin,

    The provided code requires that the test Testimonials theme is being used. Can you please send me the code you’re using where you added that theme?

    If you haven’t done that yet, this is possible by modifying the form.

  2. Constantin Kriptonitov 8 years, 3 months ago

    Alex, thanks a lot! I missing this part, but now this works fine! This is how i am modified button example to use width testimonials widget:

    //custom testimonials template
    function mytheme_extend_testimonials_form( $form_options, $widget ){
        // Lets add a new layout option
        if( !empty($form_options['design']['fields']['layout']['options']) ) {
            $form_options['design']['fields']['layout']['options']['test'] = __('Test Style', 'mytheme');
        }
        return $form_options;
    }
    add_filter('siteorigin_widgets_form_options_sow-testimonials', 'mytheme_extend_testimonials_form', 10, 2);
    function mytheme_testimonials_template_file( $filename, $instance, $widget ){
        if( !empty($instance['design']['layout']) && $instance['design']['layout'] == 'test' ) {
            // And this one for themes
            $filename = get_stylesheet_directory() . '/tpl/1.php';  // this modify copy of original default.php in widget dirrectory
        }
        return $filename;
    }
    add_filter( 'siteorigin_widgets_template_file_sow-testimonials', 'mytheme_testimonials_template_file', 10, 3 );

    Now i can choose my own template in widget front-end editor!

Replies on this thread are closed.

Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Have a different question or issue?

Start New Thread