How to override template functions

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #726815
    Nicolas Kuhn


    Is there a way to override php functions located in the template-functions.php file at the plugin directory root ?

    An example would be the mphb_tmpl_the_room_reservation_form() function as I would like to rename the “Confirm reservation” button… I could modify it directly in this file but then I lose all plugin upgrading ability as it would overwrite any change in native plugin files I suppose…


    Stacy Lind

    Hi Nicolas,

    The file template-functions.php cannot be overridden. We do not recommend editing the plugin files. Renaming can be done easier and safer with a translation plugin:
    1. Install a translation plugin e.g. Loco Translate from and activate it.
    2. Navigate to Dashboard > Loco Translate > Plugins and click Hotel Booking.
    3. Click New Language.
    4. Choose the language of your WordPress.
    5. Use the filter field to find all strings with phrases that you want to change.
    6. Insert your own phrases as translation.
    7. Save and check the result.

    This way the change will not be lost during update.

    Manuel Sosi

    and what about if we need/want to override a function? like for example if we would like 3 columns instead of 4 in template-functions.php

    function mphb_tmpl_the_single_room_type_gallery(){

    $galleryAtts = array(
    ‘link’ => apply_filters( ‘mphb_single_room_type_gallery_image_link’, ‘file’ ),
    ‘columns’ => apply_filters( ‘mphb_single_room_type_gallery_columns’, ‘4’ ),
    ‘size’ => apply_filters( ‘mphb_single_room_type_gallery_image_size’, ‘thumbnail’ ),
    ‘mphb_wrapper_class’ => apply_filters( ‘mphb_single_room_type_gallery_wrapper_class’, ‘mphb-single-room-type-gallery-wrapper’ )

    mphb_tmpl_the_room_type_galery( $galleryAtts );

    J. Davis

    Hi Manuel,

    Thank you for your question. You may modify it by adding filters e.g.:

    add_filter( 'mphb_single_room_type_gallery_columns', 'theme_mphb_single_room_type_gallery_columns' );
    function theme_mphb_single_room_type_gallery_columns() {
        return 3;

    best regards,
    J. Davis

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.