0

I know this is probably basic Wordpress coding but how would I achieve this?

Use the filter “wcvendors_pro_table_display_rows_path” — and return a path to the new template file. (/plugins/wc-vendors-pro/public/class-wcvendors-pro-table-helper.php Line #328.)

Line #328 of plugins/wc-vendors-pro/public/class-wcvendors-pro-table-helper.php is:

public function display_rows() {

        include apply_filters( 'wcvendors_pro_table_display_rows_path', 'partials/helpers/table/wcvendors-pro-table-data.php' );

    }

I have created a duplicate of wcvendors-pro-table-data.php in my child theme.

4
  • Does this answer your question? How apply_filters work in WordPress?
    – kero
    Oct 28 '21 at 9:59
  • As a total newbie to Wordpress development it doesn't - I tried using that guide but still don't really know what I am doing...thank for responding though @kero Oct 28 '21 at 10:11
  • Can you elaborate what exactly you don't understand? The topic of filters and actions is widely covered, as it is core element in WP development. I understand in the beginning it might be difficult to grip - similarly it is difficult for me to help without fully understanding what your problem with the concept is.
    – kero
    Oct 28 '21 at 10:21
  • Sorry I will try and explain...the file wcvendors-pro-table-data.php is in a directory that can't be edited without being wiped when the plugin is updated. The developer suggested that I use the filter 'wcvendors_pro_table_display_rows_path' to specific a path to the new file that will be in my child theme folder and hence not be wiped when updated. Using actions and filters is like a minefield and so I appreciate any advice. Oct 28 '21 at 10:28
2

Create the template you want to use, say wc-vp-table-rows.php, put it in your theme, and add the following to your functions.php:

add_filter( 
    'wcvendors_pro_table_display_rows_path', 
    fn() => locate_template( 'wc-vp-table-rows.php' )
);

locate_template() returns a complete path; it also searches in parent and child themes.

1
  • 1
    Something to take into account, PHP arrow function, fn (argument_list) => expr, is a single line only and is available for version >= 7.4, so if you ecnouter any problems with this use a regular anonymous function. Oct 28 '21 at 12:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.