I'm trying to change the_content of Wordpress posts in the single page (woocommerce, it's products) using the filterhook “the_content", which works fairly neat – only if there IS NO CONTENT in that post (product without detailed description) my theme doesn't even show the content container, thus never even calling the_content. I do not have access to the functions, I insert snippets – whrere would I have to check against empty content, and how could I alter it (can I, at all?) without updating the post in the DB?
Here's what works, if the content consists of even a single character:
add_filter('the_content','produktbeschrieb',-1);
function produktbeschrieb($content) {
$kategorien = get_the_term_list( $post->ID, 'product_cat', '', ', ') ;
if ( is_singular() && in_the_loop() && is_main_query() ) {
if(str_contains($kategorien,'R&F Pigment Sticks')){
return $content."<p>R&F Pigment Sticks® sind Ölfarben, die so viel Wachs enthalten, dass die Farbe in Stäbchenform gegossen werden kann. </p>";
}
else {
return $content;}
}