0

i use the function below to show content under the_content. It works on pages which uses template-test.php. But on other pages the_content stops output.

function beschreibung_kriterien( $content ) {

    if ( is_page_template( 'template-test.php' ) ) {

        $content .= '<h2>Test</h2>';

        return $content;
    }
}
add_filter( 'the_content', 'beschreibung_kriterien', 5 );
1

Because you only return $content from inside your if - you should always return it:

function beschreibung_kriterien( $content ) {
    if ( is_page_template( 'template-test.php' ) ) {
         $content .= '<h2>Test</h2>';
    }

    return $content;
}

add_filter( 'the_content', 'beschreibung_kriterien', 5 );

This just goes to the show the importance of proper indentation!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.