I want to display a Custom title on woocommerce archive/category pages.
So i created a Cusomt Term field and i can see it in the archive / category edit window on backend.
how can i display it on the frontend after / instead of the standard title?
i use shoptimizer theme.
Is there any documentation that you are following?
No
However you will need to replace "my-field" with the slug of your field. If this hook doesn't work then you will perhaps need to consult with the Woocommerce support team to see how best you can replace the title with the custom field as the types_render_termeta() function is used to get the custom field value in php.
At this point i'm at a loss. All the indications point to the "woocommerce_show_page_title" hook but so far it has failed to modify the title of the page.
What I recommend here is that you get in touch with the Woocommerce support team for them to check to see why this hook isn't working.
I got it when i use it with shortcode:
add_filter( 'woocommerce_page_title', 'customize_woocommerce_page_title', 10, 1 );
function customize_woocommerce_page_title( $page_title) {
// Custom title for the product category
if ( is_product_category() ) {
$page_title = do_shortcode( '[types termmeta="eigener-kategorie-titel"][/types]' );
}
return $page_title;
}
but why it dont work the firstway?
And if the field"eigener-kategorie-titel' is empty it should return normal page title ... thats missing.
Happy to see you were able to find a hook that works.
but why it dont work the firstway?
Not sure what you mean by this, however if you're referring to the Hook then this is a completely different hook that the one I found on the woocommerce docs.
add_filter( 'woocommerce_page_title', 'customize_woocommerce_page_title', 10, 1 );
function customize_woocommerce_page_title( $page_title) {
$new_title = do_shortcode( '[types termmeta="eigener-kategorie-titel" output='raw'][/types]' );
// Custom title for the product category
if ( is_product_category() && !empty($new_title) ) {
$page_title = do_shortcode( '[types termmeta="eigener-kategorie-titel"][/types]' );
}
return $page_title;
}
If you use the above code it should now account for if the field value is missing.