• ojs81

    (@ojs81)


    Hi folks, I’d like to be able to display the custom field pa_book_author beneath each product title on the Wishlist page (in this case a book’s author beneath each book title). Any guidance you could give on how best to achieve this would be much appreciated, cheers!

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Juan Coronel

    (@juaancmendez)

    Hi there,
    thanks for contacting us!

    To achieve what you need please add the following code in the functions.php file of your active theme:

    if (!function_exists('yith_wcwl_table_after_product_name_custom')) {
    function yith_wcwl_table_after_product_name_custom( $item ) {
    $product = $item->get_product();
    $text = get_post_meta( $product->get_id(), 'pa_book_author' , true );
    echo '<br>' . wp_kses_post( $text );
    }
    add_action( 'yith_wcwl_table_after_product_name', 'yith_wcwl_table_after_product_name_custom', 99 );
    }

    Could you check it, please?

    Best regards.

    Thread Starter ojs81

    (@ojs81)

    Thanks so much for this!

    Having added the code, the field is now displayed although the format changes (last name, first name, as opposed to first name last name everywhere else it’s displayed). Any thoughts on what might cause this?

    Also would it be straightforward to display pa_author_name beneath the product title on a new line title rather than immediately following it on the same line, please?

    Thread Starter ojs81

    (@ojs81)

    Now I think of it, the reversed display format is the same as the field’s slug rather than it’s name. Not sure if this could be a factor but it’s all I could think of.

    Plugin Support Juan Coronel

    (@juaancmendez)

    Hello there,

    Sorry, but we don’t have any control over how that custom field is displayed. If you have any questions about that, I recommend contacting the support of the plugin that creates that field.

    If you want to add the field as well, please modify the code above to the following:

    if (!function_exists('yith_wcwl_table_after_product_name_custom')) {
    function yith_wcwl_table_after_product_name_custom( $item ) {
    $product = $item->get_product();
    $text = get_post_meta( $product->get_id(), 'pa_author_name' , true );
    echo '<br>' . wp_kses_post( $text );
    }
    add_action( 'yith_wcwl_table_after_product_name', 'yith_wcwl_table_after_product_name_custom', 99 );
    }

    Check it out and tell us any doubt, please.

    Best regards.

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