• Resolved Lorangeo

    (@lorangeo)


    Hi,

    Is it possible to show the author name (user who submitted the product), ideally with a link to its profile, and the date of publication on the single Product page? Could someone help me find the right code please?

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Stef

    (@serafinnyc)

    You’ll need to add meta boxes to the single products. Check out this article on how to achieve that. if you don’t want to use an app you’ll need a developer to hook that area for you.

    Thread Starter Lorangeo

    (@lorangeo)

    I managed to achieve that with the following code:

    add_action( 'woocommerce_single_product_summary', 'show_product_author_and_date', 25 );
    function show_product_author_and_date() {
        global $post;
        $author_id = $post->post_author;
        $author_name = get_the_author_meta( 'display_name', $author_id );
        $author_link = get_author_posts_url( $author_id );
        $publication_date = get_post_time( 'F j, Y', false, $post, true );
        echo '<p class="product-author">Author: <a href="' . esc_url( $author_link ) . '">' . esc_html( $author_name ) . '</a></p>';
        echo '<p class="product-date">Publication Date: ' . esc_html( $publication_date ) . '</p>';
    }
    Stef

    (@serafinnyc)

    You said you needed it to be “submitted”. This would not be a submission. This would be “created” product. So, all you needed was the default WP author and date. Glad you got what you needed.

    Hey, @lorangeo!

    From what I understand you were able to solve the issue, correct?

    Thank you for sharing the solution here and contributing to the WooCommerce Community. This might help other users in the future.

    If you need further help with the code, you can visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there too.

    Please let us know if there’s anything else we can do to help or if you have any questions.

    Have a wonderful day!

    Thread Starter Lorangeo

    (@lorangeo)

    Thanks to both of you for your help! Yes, the code above solved my issue ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Show author name + date of publication on Product page’ is closed to new replies.