Show Section Breaks on Post Page
-
Hi,
I am trying to work out how to show the section breaks that are on the form on the post page on my website.
I read this forum post: https://wedevs.com/support/topic/front-end-formatting/
and tried inserting the code provided into my wpuf_functions.php file. However, when I uploaded the file, the post page showed up as a blank page. Is there something I am doing wrong? This is what I did:Replaced
function wpuf_show_custom_fields( $content ) { global $post; $show_custom = wpuf_get_option( 'cf_show_front', 'wpuf_general' ); if ( $show_custom != 'on' ) { return $content; } $form_id = get_post_meta( $post->ID, '_wpuf_form_id', true ); if ( !$form_id ) { return $content; } $html = '<ul class="wpuf_customs">'; $form_vars = get_post_meta( $form_id, 'wpuf_form', true ); $meta = array(); if ( $form_vars ) { foreach ($form_vars as $attr) { if ( isset( $attr['is_meta'] ) && $attr['is_meta'] == 'yes' ) { $meta[] = $attr; } } if ( !$meta ) { return $content; } foreach ($meta as $attr) { $field_value = get_post_meta( $post->ID, $attr['name'] ); if ( $attr['input_type'] == 'hidden' ) { continue; } if ( $attr['input_type'] == 'image_upload' || $attr['input_type'] == 'file_upload' ) { $image_html = '<li><label>' . $attr['label'] . ':</label> '; if ( $field_value ) { foreach ($field_value as $attachment_id) { if ( $attr['input_type'] == 'image_upload' ) { $thumb = wp_get_attachment_image( $attachment_id, 'thumbnail' ); } else { $thumb = get_post_field( 'post_title', $attachment_id ); } $full_size = wp_get_attachment_url( $attachment_id ); $image_html .= sprintf( '<a href="%s">%s</a> ', $full_size, $thumb ); } } $html .= $image_html . '</li>'; } elseif ( $attr['input_type'] == 'map' ) { ob_start(); wpuf_shortcode_map_post($attr['name'], $post->ID); $html .= ob_get_clean(); } else { $value = get_post_meta( $post->ID, $attr['name'] ); $html .= sprintf( '<li><label>%s</label>: %s</li>', $attr['label'], make_clickable( implode( ', ', $value ) ) ); } } } $html .= '</ul>'; return $content . $html; } add_filter( 'the_content', 'wpuf_show_custom_fields' );
With:
function wpuf_show_custom_fields( $content ) { global $post; $show_custom = wpuf_get_option( 'cf_show_front', 'wpuf_general' ); if ( $show_custom != 'on' ) { return $content; } $form_id = get_post_meta( $post->ID, '_wpuf_form_id', true ); if ( !$form_id ) { return $content; } $html = '<ul class="wpuf_customs">'; $form_vars = get_post_meta( $form_id, 'wpuf_form', true ); $meta = array(); if ( $form_vars ) { foreach ($form_vars as $attr) { if ( $attr['input type'] == 'section break' ) { $html .= '<li>'; $html .= '<h2>' . $attr['label'] . '<h2>'; $html .= '<div class="details">' . $attr['description'] . '</div>'; $html .= '</li>' } else if ( isset( $attr['is meta'] ) && $attr['is_meta'] == 'yes' ) { $field_value = get_post_meta( $post->ID, $attr['name'] ); if ( $attr['input_type'] == 'image_upload' || $attr['input_type'] == 'file_upload' ) { $image_html = '<li><label>' . $attr['label'] . ':</label> '; if ( $field_value ) { foreach ($field_value as $attachment_id) { if ( $attr['input_type'] == 'image_upload' ) { $thumb = wp_get_attachment_image( $attachment_id, 'thumbnail' ); } else { $thumb = get_post_field( 'post_title', $attachment_id ); } $full_size = wp_get_attachment_url( $attachment_id ); $image_html .= sprintf( '<a href="%s" rel="nofollow">%s</a> ', $full_size, $thumb ); } } $html .= $image_html . '</li>'; } else { $value = get_post_meta( $post->ID, $attr['name'] ); $html .= sprintf( '<li><label>%s</label>: %s</li>', $attr['label'], make_clickable( implode( ', ', $value ) ) ); } } } } $html .= '</ul>'; return $content . $html; }
Did I get it right? Thanks in advance.
- The topic ‘Show Section Breaks on Post Page’ is closed to new replies.