WooThemes Projects plugin - Change the location of a displayed costum field

108 Views Asked by At

I am using Woocommerce Projects plugin for WooCommerce and I have made some extra meta fields for the Projects.

But how can I display them on the place where I want them?

On this example page they show an option that will show it under the short description. But how can I change the location, to put it everywhere I want in the template file.

1

There are 1 best solutions below

3
On BEST ANSWER

Update (see below: Overriding Projects template files safely)

What you are looking at, is this documentation, that lists all possible hooks with WooCommerce "Projects" plugin.

So you will have just change the hook in:

add_action( 'projects_after_loop_item', 'display_new_projects_fields', 10 );

Replacing 'projects_after_loop_item' by one of the hooks below to change the displayed location around the loop (for example):

projects_before_loop
projects_before_loop_item
projects_loop_item
projects_after_loop_item
projects_after_loop

Or also (with the other "Projects" plugin templates):

## General layout
projects_before_main_content
projects_after_main_content
projects_sidebar

## Archives
projects_archive_description

## Single Projects
projects_before_single_project
projects_before_single_project_summary
projects_single_project_summary
projects_after_single_project_summary
projects_after_single_project

Overriding Projects template files safely

Copy the templates directory located in projects-by-woothemes plugin folder to your active child theme directory (or active theme directory) and rename it projects.

Projects plugin will always check your theme for these files before displaying core templates as a fallback. Any template files found in the theme will be given priority and the core counterpart ignored.

Now you can edit any template file as you want, adding inside it this little peace of code (from the example), directly just where you want, displaying your custom field value, just using:

echo esc_attr( get_post_meta( $post->ID, '_location', true ) );

At the end, is better to keep in that folder, only the customized templates.


Reference and related: