• Resolved officezen

    (@officezen)


    Is it possible to override the existing template via theme child?

    I tried placing the listing-added.tpl.php in theme-child (betheme)/business-directory/templates/email/ but it is not reading the file.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Jonathan Martínez

    (@jonathanenlared)

    Hi there,

    Thanks for checking on this. The listing-added email template can’t be overridden from a theme or child theme. The plugin deliberately loads this template only from its own folder, so a copy in your child theme gets skipped wherever you put it. (For other templates, overrides go in your-child-theme/business-directory/, without the templates/ folder.)

    This template is the new listing notification sent to the admin, and its content isn’t editable in the settings. The email sent to the person who submitted the listing is separate, and you can edit it in Directory > Settings > Email.

    If you want to customize the admin email anyway, you can replace its content with a filter. Here’s a starting point you can add with a plugin like WPCode. It loads your own copy from your-child-theme/business-directory/email/listing-added.tpl.php:

    add_filter( 'wpbdp_template_vars', function( $vars, $template_name ) {
    	if ( 'email/listing-added' === $template_name ) {
    		$GLOBALS['my_bd_listing_added_vars'] = $vars;
    	}
    	return $vars;
    }, 10, 2 );
    
    add_filter( 'wpbdp_render_email/listing-added', function( $content ) {
    	$file = get_stylesheet_directory() . '/business-directory/email/listing-added.tpl.php';
    	if ( file_exists( $file ) && ! empty( $GLOBALS['my_bd_listing_added_vars'] ) ) {
    		$content = wpbdp_render_page( $file, $GLOBALS['my_bd_listing_added_vars'], false );
    	}
    	return $content;
    } );

    Please test this on a staging site first. Custom code is outside what we can fully support, but this should get you started.

    Thread Starter officezen

    (@officezen)

    I will test the code snippet.

    In the meantime, please note for your future release to add a single space after the ‘Posted By’ text. Currently the output in the email has no space.

    Line 30: esc_html_e( ‘Posted By’, ‘business-directory-plugin’ ) . ‘: ‘;

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.