Exclude comment_form from cache with mfunc (fragment caching)
-
Hi Guys,
I would like to exclude the comment_form() on my WooCommerce product page from cache. So i’ve been trying to use mfunc and load the comment_form() from a function in functions.php.
See below the mfunc with the function:
<!-- mfunc mycode --> show_comment_form(); <!-- /mfunc mycode -->
And here the function in functions.php:
function show_comment_form(){ $comment_form = array( 'title_reply' => __( 'Ask a question', 'surfsnb' ), 'title_reply_to' => __( 'Leave a Reply to %s', 'woocommerce' ), 'comment_notes_after' => __("PLEASE NOTE: It's not allowed to post any contact details in a question or in a reply to a question!","surfsnb"), 'fields' => array( 'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name', 'woocommerce' ) . ' <span class="required">*</span></label> ' . '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" aria-required="true" required /></p>', 'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email', 'woocommerce' ) . ' <span class="required">*</span></label> ' . '<input id="email" name="email" type="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30" aria-required="true" required /></p>', ), 'label_submit' => __( 'Submit', 'woocommerce' ), 'logged_in_as' => '', 'comment_field' => '' ); if ( $account_page_url = wc_get_page_permalink( 'myaccount' ) ) { $comment_form['must_log_in'] = '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a question.', 'woocommerce' ), esc_url( $account_page_url ) ) . '</p>'; } $comment_form['comment_field'] .= '<p class="comment-form-comment"><label for="comment">' . __( 'Your Message', 'woocommerce' ) . ' <span class="required">*</span></label><textarea id="comment" name="comment" cols="45" rows="8" aria-required="true" required></textarea></p>'; comment_form( apply_filters( 'woocommerce_product_review_comment_form_args', $comment_form ) ); }
The page I need help with: [log in to see the link]
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Exclude comment_form from cache with mfunc (fragment caching)’ is closed to new replies.