Title: Adding Product Author
Last modified: August 31, 2016

---

# Adding Product Author

 *  Resolved [jrothra](https://wordpress.org/support/users/jrothra/)
 * (@jrothra)
 * [10 years ago](https://wordpress.org/support/topic/adding-product-author/)
 * URL: [http://www.johnrothra.com/store/church-growth/1x-evangelism-kingdom-growth-strategy-local-church/](http://www.johnrothra.com/store/church-growth/1x-evangelism-kingdom-growth-strategy-local-church/)
 * I’m wanting to add the name of the author(s) underneath the item description.
   However, what I’ve tried isn’t working. So here I post.
 * **What I Tried**
    I added the custom field `product_author` under the item’s 
   custom field box, and entered the name of the author (me), clicked update under
   the new custom field just to be sure, then clicked to update the entire product
   listing.
 * I then copied the `title.php` file from _plugins/woocommerce/templates/single-
   product/_ to _theme\_child/woocommerce/templates/single-product/_. After this,
   I edited the copied file by adding an H3 under the title as so:
 *     ```
       <h1 itemprop="name" class="product_title entry-title"><?php the_title(); ?></h1>
       <h3 class="product_author"><?php echo get_post_meta($post->ID, 'product_author', TRUE); ?></h3>
       ```
   
 * I then cleared all caches and refreshed the page, but the author did not display.
   I tried altering where I put the copied file by placing it in the following locations,
   but none worked:
    - _theme\_child/woocommerce/templates/_
    - _theme\_child/woocommerce_
 * What did I do wrong or miss?
 * [https://wordpress.org/plugins/woocommerce/](https://wordpress.org/plugins/woocommerce/)

Viewing 15 replies - 1 through 15 (of 31 total)

1 [2](https://wordpress.org/support/topic/adding-product-author/page/2/?output_format=md)
[3](https://wordpress.org/support/topic/adding-product-author/page/3/?output_format=md)
[→](https://wordpress.org/support/topic/adding-product-author/page/2/?output_format=md)

 *  [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [10 years ago](https://wordpress.org/support/topic/adding-product-author/#post-7184610)
 * Try at:
    theme_child/woocommerce/single-product/title.php
 * More here:
    [https://docs.woothemes.com/document/template-structure/](https://docs.woothemes.com/document/template-structure/)
 *  Thread Starter [jrothra](https://wordpress.org/support/users/jrothra/)
 * (@jrothra)
 * [10 years ago](https://wordpress.org/support/topic/adding-product-author/#post-7184612)
 * Nope, no change.
 *  Thread Starter [jrothra](https://wordpress.org/support/users/jrothra/)
 * (@jrothra)
 * [10 years ago](https://wordpress.org/support/topic/adding-product-author/#post-7184616)
 * Just a thought: the documentation you referenced says to put the customized files
   in the theme folder, which is generally considered a no-no for WordPress. Rather,
   it’s good practice to add customizations to the child theme, which I’ve done.
 * Should I use the parent theme?
    If so, won’t any updates be undone whenever I
   update the parent?
 *  [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [10 years ago](https://wordpress.org/support/topic/adding-product-author/#post-7184617)
 * Did you empty the W3 Total Cache cache?
 *  [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [10 years ago](https://wordpress.org/support/topic/adding-product-author/#post-7184619)
 * You should use your child theme.
 *  Thread Starter [jrothra](https://wordpress.org/support/users/jrothra/)
 * (@jrothra)
 * [10 years ago](https://wordpress.org/support/topic/adding-product-author/#post-7184621)
 * I did empty the W3 cache and I have the custom files in the child theme.
 *  Thread Starter [jrothra](https://wordpress.org/support/users/jrothra/)
 * (@jrothra)
 * [10 years ago](https://wordpress.org/support/topic/adding-product-author/#post-7184622)
 * Seems like it’s got to be a code issue such as maybe I typed it wrong. I’m just
   now starting to learn PHP so I’m not very familiar with it — yet.
 *  [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [10 years ago](https://wordpress.org/support/topic/adding-product-author/#post-7184629)
 * The (empty) h3 tag is showing up in the page, so you are now using the right 
   file.
 * Try this to get the author name:
 *     ```
       <h3 class="product_author"><?php echo "Author: ".get_user_by("ID", get_post(get_the_ID())->post_author)->display_name; ?></h3>
       ```
   
 *  Thread Starter [jrothra](https://wordpress.org/support/users/jrothra/)
 * (@jrothra)
 * [10 years ago](https://wordpress.org/support/topic/adding-product-author/#post-7184635)
 * That works for now. I say for now because right now the only product would be
   my one solo book. However, should other items be added later that may include
   other authors or multiple authors, this wouldn’t work because it calls the post
   author rather than who I entered as the product author in the custom fields.
 * If I was going to do that, would I alter the code this way (seeing if I’m getting
   PHP at all, too):
 * `<h3 class="product_author"><?php echo "Author: ".get_user_by("ID", get_post(
   get_the_ID())->$post->ID, 'product_author')->display_name; ?></h3>`
 *  [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [10 years ago](https://wordpress.org/support/topic/adding-product-author/#post-7184643)
 * I don’t think there is a ‘product_author’ property. You would need to set up 
   a custom field for the product object. There are plugins to help with custom 
   fields.
 *  Thread Starter [jrothra](https://wordpress.org/support/users/jrothra/)
 * (@jrothra)
 * [10 years ago](https://wordpress.org/support/topic/adding-product-author/#post-7184650)
 * WooCommerce comes with the ability to add custom fields. Under Products, there
   is an option for “Custom Fields.” In it, I added “product_author” and entered
   my name for the value. However, it seems that isn’t recognized.
 * At least I believe it’s part of WooCommerce because I’ve never seen that option
   in the Screen Options before until I activated WC.
 *  Plugin Contributor [Mike Jolley](https://wordpress.org/support/users/mikejolley/)
 * (@mikejolley)
 * [10 years ago](https://wordpress.org/support/topic/adding-product-author/#post-7184653)
 * If you want the ‘real’ author metabox it needs to be enabled.
 * [http://wordpress.stackexchange.com/questions/74054/woocommerce-assign-an-author-to-a-product](http://wordpress.stackexchange.com/questions/74054/woocommerce-assign-an-author-to-a-product)
 *  Thread Starter [jrothra](https://wordpress.org/support/users/jrothra/)
 * (@jrothra)
 * [10 years ago](https://wordpress.org/support/topic/adding-product-author/#post-7184728)
 * Mike,
 * Looks like that option creates a user on the WP system (cf. that thread OP’s “
   I was thinking of using the wordpress built-in ‘author’ user”). Unlike that individual,
   I’m not wanting to create user accounts on the website for each individual. I’d
   rather just type in the author’s name, which makes a lot more sense in the context
   of a store system.
 * In addition, being able to add other info specific to books like publication 
   info, number of pages, etc. would be nice, but that’s for another thread. So 
   far it seems WooCommerce is good for selling some products, but not really made
   for selling books.
 *  [Peter Lawrenson](https://wordpress.org/support/users/lorro/)
 * (@lorro)
 * [10 years ago](https://wordpress.org/support/topic/adding-product-author/#post-7184730)
 * – go to Product Data section > Attributes > Custom Product attribute: “Add”
    –
   Name: = Product author – Value: = Author: Smith – at the end of title.php, add:
 *     ```
       global $product;
         $attributes = $product->get_attributes();
         foreach ($attributes as $attribute) {
           if ($attribute["name"] == "Product author") {
             $values = array_map( 'trim', explode( WC_DELIMITER, $attribute['value'] ) );
             echo apply_filters( 'woocommerce_attribute', wpautop( wptexturize( implode( ', ', $values ) ) ), $attribute, $values );
           }
         }
       ```
   
 *  Thread Starter [jrothra](https://wordpress.org/support/users/jrothra/)
 * (@jrothra)
 * [10 years ago](https://wordpress.org/support/topic/adding-product-author/#post-7184740)
 * When you say at the end of the title.php, you mean before the php closing mark(
   see below):
 *     ```
       if ( ! defined( 'ABSPATH' ) ) {
       	exit; // Exit if accessed directly
       }
       --- PUT IT HERE? ---
       ?>
       <h1 itemprop="name" class="product_title entry-title"><?php the_title(); ?></h1>
       <h3 class="product_author"><?php echo "Author: ".get_user_by("ID", get_post(get_the_ID())->post_author)->display_name; ?></h3>
       ```
   

Viewing 15 replies - 1 through 15 (of 31 total)

1 [2](https://wordpress.org/support/topic/adding-product-author/page/2/?output_format=md)
[3](https://wordpress.org/support/topic/adding-product-author/page/3/?output_format=md)
[→](https://wordpress.org/support/topic/adding-product-author/page/2/?output_format=md)

The topic ‘Adding Product Author’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [author](https://wordpress.org/support/topic-tag/author/)
 * [book-author](https://wordpress.org/support/topic-tag/book-author/)
 * [books](https://wordpress.org/support/topic-tag/books/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [templates](https://wordpress.org/support/topic-tag/templates/)

 * 31 replies
 * 3 participants
 * Last reply from: [jrothra](https://wordpress.org/support/users/jrothra/)
 * Last activity: [9 years, 9 months ago](https://wordpress.org/support/topic/adding-product-author/page/3/#post-7184881)
 * Status: resolved