Customizing fp-testimonials.php in Sydney Child Theme

Hi everyone!

First of all, I would like to thanks the whole aThemes team, you’re doing a great job.

Now, right to the point…

I just started using Wordpress and aThemes’ Sydney theme for developing my personal website:

Traducciones Pacífico

After doing some customizations here and there based on the questions and answers posted on aThemes’ Sydney support forum, I found something a little bit odd.

The following piece of code work just fine when applied at theme-level, but it goes unnoticed when applied at child-theme-level. It looks like the child-widget-code is override by its parent.

Customized piece of code, starting at line 87, in fp-testimonials.php file:


<div class="customer">
    <blockquote class="whisper"><?php the_content(); ?></blockquote>                               
    <?php if ( has_post_thumbnail() ) : ?>
    <div class="avatar">
        <a href="<?php echo esc_html($function); ?>"><?php the_post_thumbnail(); ?></a>
    </div>
    <?php endif; ?>                                
    <div class="name">
        <?php the_title(); ?>
    </div>
</div>

Original piece of code, starting at line 87, in fp-testimonials.php file:


<div class="customer">
    <blockquote class="whisper"><?php the_content(); ?></blockquote>                               
    <?php if ( has_post_thumbnail() ) : ?>
    <div class="avatar">
        <?php the_post_thumbnail(); ?>
    </div>
    <?php endif; ?>                                
    <div class="name">
        <?php the_title(); ?>
        <?php echo esc_html($function); ?>
    </div>
</div>

Could you please give me some insights to overcome this issue and avoid undesired changes due to future theme upgrades?

NB: All other customizations applied at child-theme-level, including those to footer.php and header.php files works like charm.

Hello there,

Copying a widget file to child theme won’t load in the site administration as it’s actually not tied. There some extra procedure you should do.

I assume you have widgets/fp-testimonials.php in your child theme folder.

Open this file, then replace this line (neat the most top):


class Sydney_Testimonials extends WP_Widget {

to:


class Sydney_Child_Testimonials extends WP_Widget {

Replace this line:


parent::__construct(false, $name = __('Sydney FP: Testimonials', 'sydney'), $widget_ops);

to:


parent::__construct(false, $name = __('Sydney FP: Testimonials (child)', 'sydney'), $widget_ops);

Open the functions.php file of child theme, and add this code:


/*
 * Requiring latest news widget file from childtheme
 */
require get_stylesheet_directory() . "/widgets/fp-testimonials.php";

/*
 * Registering new latest news widget
 */
function sydney_child_register_new_testimonial_widget(){
  register_widget( 'Sydney_Child_Testimonials' ); // Widget class name
}
add_action( 'widgets_init', 'sydney_child_register_new_testimonial_widget' );

Update the changes through cPanel or FTP program.

Now you can log into your site admin area and replace the existing testimonial with the “Sydney FP: Testimonials (child)” from page builder.

Regards,
Kharis

Hi Kharis,

Thank you for your prompt reply!

I followed your instructions step by step and now the customized widget works flawlessly at child-theme-level.

After a tiny little tweak in the child-theme’s style.css file the website was again up and running.

Best regards,

Aaron.

You’re welcome!

Please let us know in a new topic if you have any further questions, or if we can provide you with any other assistance.

Regards,
Kharis