Triggering text block from functions.php does not work
-
Hi,
I need a text block to be executed when a single post is displayed in the frontend. Same text block for each post.
Background.
In my website, members can fill out an extensive profile which is set up with the Meta Blocks plugin. The members enter their info in the frontend. Some general information they enter is stored in a post, but the majority of info is stored in Meta Block fields. These fields are not shown in the frontend, so therefore I am using a reusable textblock that is added to each post. In this text block each field is derived from the database and displayed in the order and layout I want.
I currently manually add this text block at the end of each post: [text-blocks id=”showfields”]So far so good.
This works perfectly, but… instead of adding the shortcode manually to each post (after my member has filled out his info in the frontend), I want the text block to be automatically executed before the post is displayed in the frontend.Therefore I have added to the functions.php:
add_filter( ‘the_content’, function( $content ) {
if ( is_single() ) {
$content .= do_shortcode( ‘[text-blocks id=”showfields”]’ );
}
return $content;
} );The result is a 503 Service Unavailable error.
When I deactivate your plugin, the shortcode [text-blocks id=”showfields”] is shown in the frontend. Hence, the functions.php seem to work, but the execution of the text block does not work.My question:
How can I trigger the reuasable text block through the functions.php?
- The topic ‘Triggering text block from functions.php does not work’ is closed to new replies.